Skip to content

Commit 66d0b86

Browse files
committed
Updated Radix Sort to Swift 4.2
1 parent 9f5e81e commit 66d0b86

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
//: Playground - noun: a place where people can play
22

3-
import Cocoa
4-
5-
// last checked with Xcode 9.0b4
6-
#if swift(>=4.0)
7-
print("Hello, Swift 4!")
8-
#endif
9-
103
// Test Radix Sort with small array of ten values
114
var array: [Int] = [19, 4242, 2, 9, 912, 101, 55, 67, 89, 32]
125
radixSort(&array)
136

147
// Test Radix Sort with large array of 1000 random values
15-
var bigArray = [Int](repeating: 0, count: 1000)
16-
var i = 0
17-
while i < 1000 {
18-
bigArray[i] = Int(arc4random_uniform(1000) + 1)
19-
i += 1
20-
}
8+
var bigArray = (0..<1000).map { _ in Int.random(in: 1...1000) }
9+
bigArray
2110
radixSort(&bigArray)

Radix Sort/RadixSort.playground/Sources/radixSort.swift

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Sorting Algorithm that sorts an input array of integers digit by digit.
44

55
*/
6-
import Foundation
76

87
// NOTE: This implementation does not handle negative numbers
98
public func radixSort(_ array: inout [Int] ) {

0 commit comments

Comments
 (0)