Pony Sorting:
You are creating an array where each element is an (age, name) pair representing guests at a Friendship is Magic party in Equestria.
You have been asked to print each guest at the party in ascending order of their ages, but if more than one guests have the same age, only the one who appears first in the array should be printed.
For example, if the input array is
[(23, Rarity), (2000, Celestia), (50, Spike), (47, TwilightSparkle), (23, Fluttershy), (83200, RainbowDash), (23, AppleJack), (47, PinkiePie), (47, Scootaloo), (150, CheeseSandwich)]
the output should be
(23, Rarity) (47, TwilightSparkle) (50, Spike) (150, CheeseSandwich) (2000, Celestia) (83200, RainbowDash)
You will read in your party goers from a file. I will pass the file name via the command line. I will only pass one argument.
Here is an example of what the input in the file will look like:
(23, Rarity)(2000, Celestia)(50, Spike)(47, TwilightSparkle)(23, Fluttershy)(83200, RainbowDash)(23, AppleJack)(47, PinkiePie)(47, Scootaloo)(150, CheeseSandwich)
So to run your code I will either type:
python ponySort.py filename.txt
or
java PonySort filename.txt
You should come up with other test cases – I will.
In your readme:
Describe a solution that takes O (1) space in addition to the provided input array. Your algorithm may modify the input array.
This party has some very old guests and your solution should still work correctly for parties that have even older guests, so your algorithm can’t assume the maximum age of the partygoers.
Give the worst-case tight-O time complexity of your solution.