Preliminary sort implementation