This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ported from https://www.raywenderlich.com/741-swift-algorithm-club-swift-merge-sort | |
func mergeSort<T: Comparable>(_ array: [T]) async -> [T] { | |
guard array.count > 1 else { return array } | |
let middleIndex = array.count / 2 | |
async let leftArray = await mergeSort(Array(array[0..<middleIndex])) | |
async let rightArray = await mergeSort(Array(array[middleIndex..<array.count])) | |
return merge(await leftArray, await rightArray) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// GradientEffect | |
// | |
// Created by Christian Privitelli on 18/7/20. | |
// | |
import SwiftUI | |
struct ContentView: View { | |