replace sortCompare function

Signed-off-by: Graham Ballantyne <grahamb@sfu.ca>