Added McDivert sorting function