Finished M sorting