renamed sorting function