Skip to content

Instantly share code, notes, and snippets.

@xodhx4
Created February 29, 2020 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xodhx4/d6a068fbdbba604dcc9a3a8bc833eba8 to your computer and use it in GitHub Desktop.
Save xodhx4/d6a068fbdbba604dcc9a3a8bc833eba8 to your computer and use it in GitHub Desktop.
[자바 정렬하기] 자바에서 배열, 리스트를 정렬하는 방법 #sort
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