๊ธ€ ์ž‘์„ฑ์ž: ์ด์ง€์›๐ŸŒฉ๏ธ

์ •๋ ฌ์— ์ ๋‹นํžˆ ์กฐ๊ฑด์„ ์ฃผ์–ด์„œ ํ‘ธ๋Š”๋ฐ, ๋ฌธ์ž์—ด์€ ์ธ๋ฑ์Šค๋กœ ์ง์ ‘ ์ ‘๊ทผ์ด ์•ˆ๋˜์„œ ๋ฐฐ์—ด๋กœ ๋ณ€ํ™˜ํ•ด์„œ ์ ‘๊ทผ, ๋น„๊ตํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ’€์—ˆ๋‹ค. ์ด๋Ÿฐ ๋ฌธ์ž์—ด๊ณผ ๊ด€๋ จ๋œ ๋ฌธ์ œ๋ฅผ ํ’€ ๋•Œ๋ฉด, ํŒŒ์ด์ฌ์œผ๋กœ ํ‘ธ๋Š” ๊ฒŒ ์ข€ ๋” ์‰ฌ์šด ๊ฑฐ ๊ฐ™๋‹ค.

๋ฌธ์ œ

https://programmers.co.kr/learn/courses/30/lessons/12915?language=swift


๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ

Swift

func solution(_ strings:[String], _ n:Int) -> [String] {
	let answer = strings.sorted(by: {
		if Array($0)[n] == Array($1)[n] {
        	return $0 < $1         
        }
        return Array($0)[n] < Array($1)[n]
    })
    
	return answer 
}
๋ฐ˜์‘ํ˜•