Created
February 29, 2020 13:26
-
-
Save xodhx4/d6a068fbdbba604dcc9a3a8bc833eba8 to your computer and use it in GitHub Desktop.
[자바 정렬하기] 자바에서 배열, 리스트를 정렬하는 방법 #sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SortEx { | |
public void main() { | |
int[] intArr = new int[3] {1, 2, 3}; | |
# 배열 오름차순 정렬 | |
Arrays.sort(intArr); | |
# 배열 내림차순 정렬 | |
Arrays.sort(intArr, Comparator.reverseOrder()); | |
# 리스트 정렬 | |
List<String> strList = Arrays.asList("1", "2", "3"); | |
Collections.sort(strList); | |
Collections.sort(strList, Comparator.reverseOrder()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment