use double sort