t: fix sort logic