{"id":2453,"date":"2016-10-03T14:59:19","date_gmt":"2016-10-03T14:59:19","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=2453"},"modified":"2016-10-03T14:59:19","modified_gmt":"2016-10-03T14:59:19","slug":"golang-%ec%a0%95%eb%a0%acsort%eb%a5%bc-%ec%9c%84%ed%95%9c-sortinterface-%ec%83%98%ed%94%8c-%ec%bd%94%eb%93%9c","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=2453","title":{"rendered":"[Golang] \uc815\ub82c(Sort)\ub97c \uc704\ud55c sort.Interface \uc0d8\ud50c \ucf54\ub4dc"},"content":{"rendered":"<p>Go\uc5d0\uc11c \ub370\uc774\ud130 \uc694\uc18c\ub4e4\uc744 \uac00\uc9c0\ub294 \uc2ac\ub77c\uc774\uc2a4\ub97c \uc815\ub82c\ud558\uae30 \uc704\ud574\uc11c\ub294 sort \ud328\ud0a4\uc9c0\uc758 Interface \uc778\ud130\ud398\uc774\uc2a4\uc758 Len, Less, Swap \ub9e4\uc11c\ub4dc\ub97c \uad6c\ud604\ud574\uc57c \ud569\ub2c8\ub2e4. \uc544\ub798\uc758 \ucf54\ub4dc\ub294 \ubb38\uc790\uc5f4 \ub370\uc774\ud130 \uc694\uc18c\ub97c \uac00\uc9c0\ub294 \uc2ac\ub77c\uc774\uc2a4\uc5d0 \ub300\ud55c \uc815\ub82c\uc5d0 \ub300\ud55c sort.Interface\uc758 \uad6c\ud604 \ucf54\ub4dc \ubc0f \ud65c\uc6a9 \ucf54\ub4dc\uc785\ub2c8\ub2e4.\n<\/p>\n<pre>\npackage main\n\nimport (\n    \"fmt\"\n    \"sort\"\n)\n\ntype StringSlice []string\n\nfunc (p StringSlice) Len() int           { return len(p) }\nfunc (p StringSlice) Less(i, j int) bool { return p[i] < p[j] }\nfunc (p StringSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }\n\nfunc main() {\n   names := []string{\"\uc774\ud6a8\uc219\", \"\uae40\ud615\uc900\", \"\uae40\uc885\uc218\", \"\uae40\uc84d\uc5f0\", \"\uae40\ub3c4\ud604\" }\n\n    fmt.Println(names)\n\n    sort.Sort(StringSlice(names))\n    \/\/sort.Strings(names)\n\n    fmt.Println(names)\n}\n<\/pre>\n<p>\uc2e4\ud589\ud574 \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 \uc815\ub82c\ub418 \uacb0\uacfc\ub97c \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre>\n[\uc774\ud6a8\uc219 \uae40\ud615\uc900 \uae40\uc885\uc218 \uae40\uc84d\uc5f0 \uae40\ub3c4\ud604]\n[\uae40\ub3c4\ud604 \uae40\uc84d\uc5f0 \uae40\uc885\uc218 \uae40\ud615\uc900 \uc774\ud6a8\uc219]\n<\/pre>\n<p>\ucc38\uace0\ub85c 19\ubc88\ub294 20\ubc88 \ucf54\ub4dc\ub85c \ub300\uccb4\uac00 \uac00\ub2a5\ud55c\ub370\uc694. \ubb38\uc790\uc5f4 \ud0c0\uc785\ucc98\ub7fc \uae30\ubcf8\ud615 \ud0c0\uc785\uc5d0 \ub300\ud55c \ub370\uc774\ud130\ub97c \uad6c\uc131\ud558\ub294 \uc2ac\ub77c\uc774\uc2a4\uc5d0 \ub300\ud55c \uc815\ub82c\uc740 \uc774\ubbf8 sort \ud328\ud0a4\uc9c0\uc5d0\uc11c \ud568\uc218\ub85c \uc81c\uacf5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go\uc5d0\uc11c \ub370\uc774\ud130 \uc694\uc18c\ub4e4\uc744 \uac00\uc9c0\ub294 \uc2ac\ub77c\uc774\uc2a4\ub97c \uc815\ub82c\ud558\uae30 \uc704\ud574\uc11c\ub294 sort \ud328\ud0a4\uc9c0\uc758 Interface \uc778\ud130\ud398\uc774\uc2a4\uc758 Len, Less, Swap \ub9e4\uc11c\ub4dc\ub97c \uad6c\ud604\ud574\uc57c \ud569\ub2c8\ub2e4. \uc544\ub798\uc758 \ucf54\ub4dc\ub294 \ubb38\uc790\uc5f4 \ub370\uc774\ud130 \uc694\uc18c\ub97c \uac00\uc9c0\ub294 \uc2ac\ub77c\uc774\uc2a4\uc5d0 \ub300\ud55c \uc815\ub82c\uc5d0 \ub300\ud55c sort.Interface\uc758 \uad6c\ud604 \ucf54\ub4dc \ubc0f \ud65c\uc6a9 \ucf54\ub4dc\uc785\ub2c8\ub2e4. package main import ( &#8220;fmt&#8221; &#8220;sort&#8221; ) type StringSlice []string func (p StringSlice) Len() int { return len(p) } func (p StringSlice) &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=2453\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[Golang] \uc815\ub82c(Sort)\ub97c \uc704\ud55c sort.Interface \uc0d8\ud50c \ucf54\ub4dc&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[113],"tags":[114,111],"class_list":["post-2453","post","type-post","status-publish","format-standard","hentry","category-golang","tag-go","tag-golang"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2453"}],"version-history":[{"count":0,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2453\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2453"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}