mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sorting was a bit of a mess; we had sort functions doing in-place mutation /and/ returing the value, and people were confused by the asymmetry of Array's sort() method with other higher-level methods. Fixes <rdar://problem/17185815> sort([]T, f) mutates the original array <rdar://problem/17225190> The Array.sort() method should return a sorted array Swift SVN r18922
24 lines
729 B
Swift
24 lines
729 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
|
|
func test() {
|
|
var array = new String[5]
|
|
array[0] = "ysmwbgmrqlmqspzcgbgxvkebesoetqcimoaemfhfzzsamgju"
|
|
array[1] = "nqbvcxdahvxzmvnqjmoilinznqyfniufgsfoeok"
|
|
array[2] = "bsqdunldltkxripsaxkaojfiovnxulshiohbumirjzgfmovowiv"
|
|
array[3] = "hepdatupehcbbdyhyjsnvtzhfupd"
|
|
array[4] = "rlrezqqlfpoktoiitbtyngyyyeoglmwxfrxjtejmyy"
|
|
array = sorted(array)
|
|
for i in array {
|
|
println(i)
|
|
}
|
|
print("\n")
|
|
}
|
|
|
|
test()
|
|
|
|
// CHECK: bsqdunldltkxripsaxkaojfiovnxulshiohbumirjzgfmovowiv
|
|
// CHECK: hepdatupehcbbdyhyjsnvtzhfupd
|
|
// CHECK: nqbvcxdahvxzmvnqjmoilinznqyfniufgsfoeok
|
|
// CHECK: rlrezqqlfpoktoiitbtyngyyyeoglmwxfrxjtejmyy
|
|
// CHECK: ysmwbgmrqlmqspzcgbgxvkebesoetqcimoaemfhfzzsamgju
|