GenerateAndSorting