I need help completing this code:
fun insertSorted(x, comp, []) = [x]
| insertSorted(x, comp, a::rest) = ??
if written correctly it would return
- insertSorted(5, fn(a, b) => a > b, [8, 6, 3, 1]);
val it = [8, 6, 5, 3, 1]
The code takes a value, a comparison function, and a list and returns a new list like the one given above. Comp is used to determine what order the values in the list should be.