(array, cmp)
| 1 | function stableSort(array, cmp) { |
| 2 | const stabilizedThis = array.map((el, index) => [el, index]); |
| 3 | stabilizedThis.sort((a, b) => { |
| 4 | const order = cmp(a[0], b[0]); |
| 5 | if (order !== 0) return order; |
| 6 | return a[1] - b[1]; |
| 7 | }); |
| 8 | return stabilizedThis.map(el => el[0]); |
| 9 | } |
| 10 | export default stableSort; |
nothing calls this directly
no outgoing calls
no test coverage detected