Files
swift-mirror/test/stdlib/sort_String.swift
Dave Abrahams acc2c3be40 [stdlib] Prepare array sort for value semantics
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
2014-06-16 13:48:43 +00:00

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