๐ŸŒCoding/๐ŸŒŸPython3

[Python] lambda

๋ฟŒ์•ผ._. 2021. 7. 29. 14:37

ํŒŒ์ด์ฌ์œผ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•ด๊ฒฐํ•  ๋•Œ ์ข…์ข… ๋ดค๋˜ ์นœ๊ตฌ์ด๋‹ค!

๋ฌผ๋ก  ์‚ฌ์šฉํ•  ๋•Œ๋งˆ๋‹ค ๊ณ„์† ๊ฒ€์ƒ‰์„ ํ–ˆ์ง€๋งŒ...

์ด์ œ๋ผ๋„ ์ •๋ฆฌํ•ด๋ณด๋ คํ•œ๋‹ค!

 

๐Ÿ˜‰ ๋žŒ๋‹ค (lambda)

 

lambda ์ธ์ž: ํ‘œํ˜„์‹

์ด๋Ÿฐ ์‹์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. 

๋ฌผ๋ก  ์ด๋ ‡๊ฒŒ๋งŒ ์จ๋†“๋Š”๋‹ค๋ฉด ๋ชจ๋ฅด๋Š” ๊ฒŒ ๋‹น์—ฐํ•˜๋‹ค! ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์‹œ๋„ ํ•จ๊ป˜ ์ ์–ด๋‘๊ฒ ๋‹ค!

 

 

numbers.sort(key=lambda x:x*4, reverse=True)

 

 

๋‹ค์ค‘ ์กฐ๊ฑด

# ๊ธฐ์ค€ ์•ž์— -๋ฅผ ๋ถ™์ด๋ฉด ๋‚ด๋ฆผ ์ฐจ์ˆœ
arr.sort(key=lambda x:(-int(x[1]), int(x[2]),-int(x[3]),x[0]))

'๐ŸŒCoding > ๐ŸŒŸPython3' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Python] list, tuple -> String  (0) 2021.09.01
[Python] heapq  (0) 2021.08.20
[Python] ์ˆœ์—ด, ์กฐํ•ฉ  (0) 2021.05.16
[Python] ๋”•์…”๋„ˆ๋ฆฌ  (0) 2021.05.02
[๊ฐ€์ƒํ™˜๊ฒฝ] ํŒŒ์ด์ฌ ํ™˜๊ฒฝ์„ค์ •  (0) 2021.03.13