stable sorting
- 정렬 후에도 기존 배열의 순서가 유지되는 정렬
[(2,b), (1,c), (3,c), (1,a)] 리스트가 있고, 숫자 기준으로 오름차순 정렬한다고 했을 때 stable sorting 을 하면
[(1,c), (1,a) , (2,b), (3,c)] 로 정렬됨. ( key 가 1인 데이터의 원본 순서가 유지되어 있음) - 종류 : selection sorting, bubble sorting
- c++ 에서는 std::stable_sort 를 쓰면 stable sorting 할 수 있다.
#include<algorithm> .... std::stable_sort(v.begin(), v.end());
unstable sorting
- 정렬 후에 기존 배열의 순서가 유지되지 않는 정렬
- 종류 : insertion sorting, quick sorting, heap sorting