Added move sorting function