Add sort stability test
This commit is contained in:
parent
d9398f1eff
commit
34f8515d44
21
test/testSortStability.krk
Normal file
21
test/testSortStability.krk
Normal file
@ -0,0 +1,21 @@
|
||||
class R:
|
||||
def __init__(self, name, department, age):
|
||||
self.name = name
|
||||
self.department = department
|
||||
self.age = age
|
||||
def __repr__(self):
|
||||
return f'Record({self.name},{self.department},{self.age})'
|
||||
|
||||
def __main__(RS,ds,ages,names):
|
||||
for i in range(50):
|
||||
RS.append(R(names[i%5],ds[i%3],ages[i%17]))
|
||||
|
||||
print(RS)
|
||||
RS.sort(key=lambda l: l.age)
|
||||
print(RS)
|
||||
RS.sort(key=lambda l: l.department)
|
||||
print(RS)
|
||||
RS.sort(key=lambda l: l.age, reverse=True)
|
||||
print(RS)
|
||||
|
||||
__main__([], ['Engineering', 'Sales', 'Management'], [n for n in range(30,47)], ['Bob','Dan','Eric','Sue','Tina'])
|
4
test/testSortStability.krk.expect
Normal file
4
test/testSortStability.krk.expect
Normal file
@ -0,0 +1,4 @@
|
||||
[Record(Bob,Engineering,30), Record(Dan,Sales,31), Record(Eric,Management,32), Record(Sue,Engineering,33), Record(Tina,Sales,34), Record(Bob,Management,35), Record(Dan,Engineering,36), Record(Eric,Sales,37), Record(Sue,Management,38), Record(Tina,Engineering,39), Record(Bob,Sales,40), Record(Dan,Management,41), Record(Eric,Engineering,42), Record(Sue,Sales,43), Record(Tina,Management,44), Record(Bob,Engineering,45), Record(Dan,Sales,46), Record(Eric,Management,30), Record(Sue,Engineering,31), Record(Tina,Sales,32), Record(Bob,Management,33), Record(Dan,Engineering,34), Record(Eric,Sales,35), Record(Sue,Management,36), Record(Tina,Engineering,37), Record(Bob,Sales,38), Record(Dan,Management,39), Record(Eric,Engineering,40), Record(Sue,Sales,41), Record(Tina,Management,42), Record(Bob,Engineering,43), Record(Dan,Sales,44), Record(Eric,Management,45), Record(Sue,Engineering,46), Record(Tina,Sales,30), Record(Bob,Management,31), Record(Dan,Engineering,32), Record(Eric,Sales,33), Record(Sue,Management,34), Record(Tina,Engineering,35), Record(Bob,Sales,36), Record(Dan,Management,37), Record(Eric,Engineering,38), Record(Sue,Sales,39), Record(Tina,Management,40), Record(Bob,Engineering,41), Record(Dan,Sales,42), Record(Eric,Management,43), Record(Sue,Engineering,44), Record(Tina,Sales,45)]
|
||||
[Record(Bob,Engineering,30), Record(Eric,Management,30), Record(Tina,Sales,30), Record(Dan,Sales,31), Record(Sue,Engineering,31), Record(Bob,Management,31), Record(Eric,Management,32), Record(Tina,Sales,32), Record(Dan,Engineering,32), Record(Sue,Engineering,33), Record(Bob,Management,33), Record(Eric,Sales,33), Record(Tina,Sales,34), Record(Dan,Engineering,34), Record(Sue,Management,34), Record(Bob,Management,35), Record(Eric,Sales,35), Record(Tina,Engineering,35), Record(Dan,Engineering,36), Record(Sue,Management,36), Record(Bob,Sales,36), Record(Eric,Sales,37), Record(Tina,Engineering,37), Record(Dan,Management,37), Record(Sue,Management,38), Record(Bob,Sales,38), Record(Eric,Engineering,38), Record(Tina,Engineering,39), Record(Dan,Management,39), Record(Sue,Sales,39), Record(Bob,Sales,40), Record(Eric,Engineering,40), Record(Tina,Management,40), Record(Dan,Management,41), Record(Sue,Sales,41), Record(Bob,Engineering,41), Record(Eric,Engineering,42), Record(Tina,Management,42), Record(Dan,Sales,42), Record(Sue,Sales,43), Record(Bob,Engineering,43), Record(Eric,Management,43), Record(Tina,Management,44), Record(Dan,Sales,44), Record(Sue,Engineering,44), Record(Bob,Engineering,45), Record(Eric,Management,45), Record(Tina,Sales,45), Record(Dan,Sales,46), Record(Sue,Engineering,46)]
|
||||
[Record(Bob,Engineering,30), Record(Sue,Engineering,31), Record(Dan,Engineering,32), Record(Sue,Engineering,33), Record(Dan,Engineering,34), Record(Tina,Engineering,35), Record(Dan,Engineering,36), Record(Tina,Engineering,37), Record(Eric,Engineering,38), Record(Tina,Engineering,39), Record(Eric,Engineering,40), Record(Bob,Engineering,41), Record(Eric,Engineering,42), Record(Bob,Engineering,43), Record(Sue,Engineering,44), Record(Bob,Engineering,45), Record(Sue,Engineering,46), Record(Eric,Management,30), Record(Bob,Management,31), Record(Eric,Management,32), Record(Bob,Management,33), Record(Sue,Management,34), Record(Bob,Management,35), Record(Sue,Management,36), Record(Dan,Management,37), Record(Sue,Management,38), Record(Dan,Management,39), Record(Tina,Management,40), Record(Dan,Management,41), Record(Tina,Management,42), Record(Eric,Management,43), Record(Tina,Management,44), Record(Eric,Management,45), Record(Tina,Sales,30), Record(Dan,Sales,31), Record(Tina,Sales,32), Record(Eric,Sales,33), Record(Tina,Sales,34), Record(Eric,Sales,35), Record(Bob,Sales,36), Record(Eric,Sales,37), Record(Bob,Sales,38), Record(Sue,Sales,39), Record(Bob,Sales,40), Record(Sue,Sales,41), Record(Dan,Sales,42), Record(Sue,Sales,43), Record(Dan,Sales,44), Record(Tina,Sales,45), Record(Dan,Sales,46)]
|
||||
[Record(Sue,Engineering,46), Record(Dan,Sales,46), Record(Bob,Engineering,45), Record(Eric,Management,45), Record(Tina,Sales,45), Record(Sue,Engineering,44), Record(Tina,Management,44), Record(Dan,Sales,44), Record(Bob,Engineering,43), Record(Eric,Management,43), Record(Sue,Sales,43), Record(Eric,Engineering,42), Record(Tina,Management,42), Record(Dan,Sales,42), Record(Bob,Engineering,41), Record(Dan,Management,41), Record(Sue,Sales,41), Record(Eric,Engineering,40), Record(Tina,Management,40), Record(Bob,Sales,40), Record(Tina,Engineering,39), Record(Dan,Management,39), Record(Sue,Sales,39), Record(Eric,Engineering,38), Record(Sue,Management,38), Record(Bob,Sales,38), Record(Tina,Engineering,37), Record(Dan,Management,37), Record(Eric,Sales,37), Record(Dan,Engineering,36), Record(Sue,Management,36), Record(Bob,Sales,36), Record(Tina,Engineering,35), Record(Bob,Management,35), Record(Eric,Sales,35), Record(Dan,Engineering,34), Record(Sue,Management,34), Record(Tina,Sales,34), Record(Sue,Engineering,33), Record(Bob,Management,33), Record(Eric,Sales,33), Record(Dan,Engineering,32), Record(Eric,Management,32), Record(Tina,Sales,32), Record(Sue,Engineering,31), Record(Bob,Management,31), Record(Dan,Sales,31), Record(Bob,Engineering,30), Record(Eric,Management,30), Record(Tina,Sales,30)]
|
Loading…
Reference in New Issue
Block a user