Homeamorphic sort