์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- DP
- ์๋ฎฌ๋ ์ด์
- HashMap
- ์๊ณ ๋ฆฌ์ฆ
- BOJ
- ๊ตฌํ
- ์ฌ๊ท
- ๋นํธ๋ง์คํน
- ๋ธ๋ฃจํธํฌ์ค
- ํ๋ก์ด๋์์ฌ
- Python
- bfs
- ๋ถ๋ถ์งํฉ
- Deque
- SQL
- ํ๋ก๊ทธ๋๋จธ์ค
- ์ ๋ ฌ
- ๋ถํ ์ ๋ณต
- dfs
- ๋ฌธ์์ด
- ์กฐํฉ
- ๋ค์ต์คํธ๋ผ
- ๋ฐฑํธ๋ํน
- heapq
- ๋ฐฐ๋ญ๋ฌธ์
- ์ด๋ถํ์
- ์๋๋ก์ด๋
- Java
- ํ์ด์ฌ
- 3์ฐจ์๋ฐฐ์ด
- Today
- Total
๋ชฉ๋ก์ ๋ ฌ (4)
It's easy, if you try
Map map = new HashMap(); map.put("a", 3); map.put("b", 2); map.put("c", 1); List entryList = new LinkedList(map.entrySet()); entryList.sort(((o1, o2) -> map.get(o1.getKey()) - map.get(o2.getKey()))); for(Map.Entry entry : entryList){ System.out.println("key : " + entry.getKey() + ", value : " + entry.getValue()); } //key : c, value : 1 //key : b, value : 2 //key : a, value : 3
๋ชฉ์ฐจ 1. Collections ์ Sort 2. Comparable 3. Comparator 4. Comparator ์ต๋ช ์ ๋ด๋ถ ํด๋์ค ์ฌ์ฉํ๊ธฐ 5. ๋๋ค์์ผ๋ก ํํํ๊ธฐ Collections.sort ์ฌ์ฉํ๊ธฐ Collections.sort() ๋ฅผ ์ด์ฉํด ๊ฐ์ฒด๋ฅผ ์ค๋ฆ์ฐจ์ ๋๋ ๋ด๋ฆผ์ฐจ์์ผ๋ก ์ ๋ ฌํ ์ ์๋ค. Arrays.sort()์ ๊ฒฝ์ฐ Collection(List) ์ ๋ ฌ์ ๋ถ๊ฐ๋ฅํ๋ค. ๋ฐฐ์ด ๊ฐ์ฒด์ ๊ฒฝ์ฐ๋ง ๊ฐ๋ฅํ๋ค.(๊ธฐ๋ณธ์ ์ค๋ฆ์ฐจ์, Arrays.sort(๋ฐฐ์ด ์ด๋ฆ, Collections.reverseOrder()); ==> ๋ด๋ฆผ์ฐจ์) ๋ง์ฝ ์ฌ์ฉ์๊ฐ ์ ๋ ฌ ์กฐ๊ฑด์ ๋ค์ ์ ์ํ๊ณ ์ถ๋ค๋ฉด 1. Comparable (๊ตฌํ, compareTo ๋ฉ์๋ ์ค๋ฒ๋ผ์ด๋ฉ) 2. Comparator (๊ตฌํ, compare ..
๋ฌธ์ JUNGOL www.jungol.co.kr ํ์ด import java.io.*; import java.util.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static int N; static int RefreNum; private static class Temperatures implements Comparable { int min; int max; public Temperatures(int min, int max) { this.min = min; this.max = max; } @Override public ..
1์ฐจ์๋ฐฐ์ด ์ ๋ ฌ ์ข์์ ์ฐ๋ก ์ ๋ ฌ: np.sort(x) ๊ฑฐ๊พธ๋ก ์ ๋ ฌ: np.sort(x)[::-1] , x[np.argsort(-x)] 2์ฐจ์๋ฐฐ์ด ์ ๋ ฌ ์ด ์ถ ๊ธฐ์ค(์ข์์ ์ฐ๋ก)์ผ๋ก ์ ๋ ฌ : np.sort(x, axis=1) ํ ์ถ ๊ธฐ์ค(์์์ ์๋๋ก)์ผ๋ก ์ ๋ ฌ: np.sort(x, axis=0) ํ ์ถ ๊ธฐ์ค(์์์ ์๋๋ก)์ผ๋ก ๊ฑฐ๊พธ๋ก ์ ๋ ฌ: np.sort(x, axis=0)[::-1] ์์ np.sort(x) x = np.array([3,5,1]) --- ์ ๋ ฌ ํ ---> array([1,3,5]) np.sort(x)[::-1] , x[np.argsort(-x)] x = np.array([3,5,1]) --- ์ ๋ ฌ ํ ---> array([5,3,1]) np.sort(x, axis=1) x = np.a..