Sorting the dictionaries in a list

๊น€ํ•œ์ค€ยท2021๋…„ 7์›” 11์ผ
0

๐Ÿš€ ๋ฆฌ์ŠคํŠธ์•ˆ์— ์žˆ๋Š” ๋”•์…”๋„ˆ๋ฆฌ ์ •๋ ฌ

๐Ÿ”ฅ sorted() + lambda

  • iterable ์ž๋ฆฌ์—๋Š” dict, list, str ๊ฐ€๋Šฅ
  • key๋Š” ์š”์†Œ๋ฅผ ๋น„๊ตํ• ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ์ค€์„ ์ •ํ•˜๋Š” ํ•จ์ˆ˜
  • Reverse = Ture, ๋‚ด๋ฆผ์ฐจ์ˆœ
    Reverse = False, ์˜ค๋ฆ„์ฐจ์ˆœ
soreted(iterable, key=None, reverse=false)
  • dictionary case

  • tuple case

๐Ÿ”ฅ sorted() + itemgetter


reverse๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด lambda๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ์™€ ๊ฐ™์ด ์—ญ์œผ๋กœ ์ •๋ ฌ ๊ฐ€๋Šฅ

0๊ฐœ์˜ ๋Œ“๊ธ€