Skip to content

Commit ecff778

Browse files
authored
Fix smart sort bug (#43)
* extended smart sort to 3rd and 4th fields * up version * fixed typo
1 parent 4bb7c24 commit ecff778

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

pyard/smart_sort.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,37 @@ def smart_sort_comparator(a1, a2):
3333
return 1
3434

3535
# If the first fields are equal, try the 2nd fields
36-
a1_f2 = int(a1[a1.find(':')+1:])
37-
a2_f2 = int(a2[a2.find(':')+1:])
36+
37+
a1_f2 = int(a1.split(':')[1])
38+
a2_f2 = int(a2.split(':')[1])
3839

3940
if a1_f2 < a2_f2:
4041
return -1
4142
if a1_f2 > a2_f2:
4243
return 1
4344

45+
# If the two fields are equal, try the 3rd fields
46+
47+
a1_f3 = int(a1.split(':')[2])
48+
a2_f3 = int(a2.split(':')[2])
49+
50+
if a1_f3 < a2_f3:
51+
return -1
52+
if a1_f3 > a2_f3:
53+
return 1
54+
55+
# If the two fields are equal, try the 4th fields
56+
57+
a1_f4 = int(a1.split(':')[3])
58+
a2_f3 = int(a2.split(':')[3])
59+
60+
if a1_f4 < a2_f4:
61+
return -1
62+
if a1_f4 > a2_f4:
63+
return 1
64+
65+
66+
4467
# All fields are equal
4568
return 0
4669

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
setup(
4444
name='py-ard',
45-
version='0.0.17',
45+
version='0.0.18',
4646
description="ARD reduction for HLA with python",
4747
long_description=readme + '\n\n' + history,
4848
author="CIBMTR",

0 commit comments

Comments
 (0)