added sort compare - fully copied from sedgewick