Sort with comparator function (closure)