sort with repeat working (seems good)