[TIL] 112 [C#] list์ •๋ ฌ,๋žŒ๋‹ค

์—…๋ฐ์ดํŠธ:

์นดํ…Œ๊ณ ๋ฆฌ:

ํƒœ๊ทธ: ,


list์ •๋ ฌ ๋žŒ๋‹ค



์ •๋ ฌ

๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋กœ ์ •๋ ฌ, ์ˆœ์„œ๋Œ€๋กœ์ •๋ ฌ


List<string> list = words.ToList();

list.Sort((x, y) =>
{
    if (x.Length == y.Length)
    {
        return x.CompareTo(y);
    }
    else
    {
        return x.Length.CompareTo(y.Length);
    }
});

  • hashset -> ์ค‘๋ณต์ œ๊ฑฐ
  • sort -> ๊ธธ์ด, ์‚ฌ์ „์ˆœ ์ •๋ ฌ





์žก๋‹ด, ์ผ๊ธฐ?

์ด๋ ฅ์„œ ์ •๋ฆฌ, ์ž์†Œ์„œ ์ž‘์„ฑ, ๋ฉด์ ‘์ค€๋น„์ค‘, ์ฝ”ํ…Œ




๐Ÿ“”

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ