0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Swift】配列を文字列の長さ順に並び替える方法

Posted at

はじめに

同じことをやる方がいると思うので記事にしておきます。

並び替え方法

var array = ["キリン", "ゾウ", "シマウマ", "アライグマ"]
array.sort { $0.count > $1.count }

print(array)
// ["アライグマ", "シマウマ", "キリン", "ゾウ"]

おわり

$0とか$1がなんなのか全く分かってません笑

0
1
1

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?