Fixing thenBy to properly sort