0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】sorted()関数とreversed()関数

Posted at

sorted()関数は、引数のイテラブルを辞書順に並び替えてリストを返します。

sorted()関数の引数で「reverse=True」を付けると、降順に並び替えてリストを返します。

reversed()関数は、引数のイテラブルを逆順に並び替えてイテレーターを返します。降順ではなく逆順です。また、戻り値はイテレーターのため、リストを取得したい場合はlist()関数で変換します。

sorted()関数とreversed()関数は非破壊のため、引数で取得した変数の内容に影響はありません。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?