@@ -0,0 +1,1482 @@
+from PySortAlgos import *%0D%0A%0D%0Adef example_1():%0D%0A    persons = %7B%22Thomas%22:21, %22Ursula%22:58, %22Mike%22:19, %22Max%22:30, %22Tina%22:21%7D%0D%0A    %0D%0A    person_sortedKeysByAge1 = BubbleSort(key=lambda p: persons%5Bp%5D).sort(persons.keys())%0D%0A    person_sortedKeysByAge2 = QuickSort(key=lambda p: persons%5Bp%5D).sort(persons.keys())%0D%0A    %0D%0A    print(%22Sorted with BubbleSort (stable):%22)%0D%0A    for key in person_sortedKeysByAge1:%0D%0A        print(%22%7B%7D (%7B%7D)%22.format(key, persons%5Bkey%5D))%0D%0A    %0D%0A    print(%22%5CnSorted with QuickSort (not so stable):%22)%0D%0A    for key in person_sortedKeysByAge2:%0D%0A        print(%22%7B%7D (%7B%7D)%22.format(key, persons%5Bkey%5D))%0D%0A%0D%0Adef example_2():%0D%0A    class Person(object):%0D%0A        def __init__(self, name, age):%0D%0A            self.name = name%0D%0A            self.age = age%0D%0A        %0D%0A        def __str__(self, *args, **kwargs):%0D%0A            return %22%7B%7D (%7B%7D)%22.format(self.name, self.age)%0D%0A    %0D%0A    persons = %5BPerson(%22Thomas%22, 21), Person(%22Ursula%22, 58), Person(%22Mike%22, 19), Person(%22Max%22, 30), Person(%22Tina%22, 21)%5D%0D%0A    %0D%0A    persons_sortedByName = BubbleSort(compare=lambda x,y: 0 if x==y else (-1 if x%3Cy else 1), key=lambda p: p.name.upper()).sort(persons)%0D%0A    persons_sortedByAge = BubbleSort(key=lambda p: p.age).sort(persons)%0D%0A    %0D%0A    %0D%0A    print(%22Index%5Ctpre sorted%5Ctsorted by age%5Ctsorted by name%22)%0D%0A    for i in range(len(persons)):%0D%0A        print(%22%7B%7D%5Ct%7B%7D%5Ct%7B%7D%5Ct%7B%7D%22.format(i, persons%5Bi%5D, persons_sortedByAge%5Bi%5D, persons_sortedByName%5Bi%5D))%0D%0A%0D%0A%0D%0Aif __name__ == %22__main__%22:%0D%0A    example_1()%0D%0A    example_2()

Append Example.py