LoginSignup
0
0

More than 5 years have passed since last update.

Xcode7ではsortedがなくなっているようだ

Posted at

以下のコードをXcode7.0のPlayGroundで書いてみた

var ageArray = [34,23,31,26,22]
ageArray.sort{$0 < $1}
print(ageArray)

結果は以下の通り

[34, 23, 31, 26, 22]
(11 times)
"[34, 23, 31, 26, 22]\n"

なので、以下のようにすれば、正しく動いた

var ageArray = [34,23,31,26,22]
var sortedAgeArray = ageArray.sort{$0 < $1}
print(sortedAgeArray)

どうやら、sortの挙動が前と異なっていて、古いsortedの挙動がsortになって、古いsortの挙動はなくなっているようである。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0