{"id":18208,"date":"2021-08-26T10:42:11","date_gmt":"2021-08-26T05:12:11","guid":{"rendered":"https:\/\/python-programs.com\/?p=18208"},"modified":"2021-11-22T18:37:14","modified_gmt":"2021-11-22T13:07:14","slug":"python-program-for-alternative-sorting","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-alternative-sorting\/","title":{"rendered":"Python Program for Alternative Sorting"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Sort a List Containing Two Types of Elements<\/a>
\nGiven a list and the task is to Print the list so that the first element is the first maximum, the second element is the first minimum, and so on.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [2, 3, 7, 8, 1, 3, 6]<\/pre>\n

Output:<\/strong><\/p>\n

The Alternative sorting of the above given list is :\r\n8 1 7 2 6 3 3<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [2, 1, 7, 4, 1, 2, 5]<\/pre>\n

Output:<\/strong><\/p>\n

The Alternative sorting of the above given list is :\r\n7 1 5 1 4 2 2<\/pre>\n

Program for Alternative Sorting in Python<\/h2>\n

Below are the ways to Print the list so that the first element is the first maximum, the second element is the first minimum, and so on.<\/p>\n