* pythonの「リスト(list), 辞書(dict), setのソート(sorted)」

:CATEGORIES: python


In [1]: users = {'a1', 'b1', 'fukazawas', 'lawks', 'lawks2', 'motoken_tw', 'uwaaa'}

In [2]: users
Out[2]: {'a1', 'b1', 'fukazawas', 'lawks', 'lawks2', 'motoken_tw', 'uwaaa'}

In [3]: users.add('z1')

In [4]: users
Out[4]: {'a1', 'b1', 'fukazawas', 'lawks', 'lawks2', 'motoken_tw', 'uwaaa', 'z1'}

In [5]: sorted(users)
Out[5]: ['a1', 'b1', 'fukazawas', 'lawks', 'lawks2', 'motoken_tw', 'uwaaa', 'z1']

In [6]: sorted(users, reverse=True)
Out[6]: ['z1', 'uwaaa', 'motoken_tw', 'lawks2', 'lawks', 'fukazawas', 'b1', 'a1']

リスト(list), 辞書(dict), setのソート(sorted) | Python Snippets https://python.civic-apps.com/sort-sorted/

 少しずつpythonの勉強。