Sorting code adding