Skip to content

Commit

Permalink
Fix smart sort bug (#43)
Browse files Browse the repository at this point in the history
* extended smart sort to 3rd and 4th fields

* up version

* fixed typo
  • Loading branch information
mmaiers-nmdp committed Jul 29, 2020
1 parent 4bb7c24 commit ecff778
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions pyard/smart_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,37 @@ def smart_sort_comparator(a1, a2):
return 1

# If the first fields are equal, try the 2nd fields
a1_f2 = int(a1[a1.find(':')+1:])
a2_f2 = int(a2[a2.find(':')+1:])

a1_f2 = int(a1.split(':')[1])
a2_f2 = int(a2.split(':')[1])

if a1_f2 < a2_f2:
return -1
if a1_f2 > a2_f2:
return 1

# If the two fields are equal, try the 3rd fields

a1_f3 = int(a1.split(':')[2])
a2_f3 = int(a2.split(':')[2])

if a1_f3 < a2_f3:
return -1
if a1_f3 > a2_f3:
return 1

# If the two fields are equal, try the 4th fields

a1_f4 = int(a1.split(':')[3])
a2_f3 = int(a2.split(':')[3])

if a1_f4 < a2_f4:
return -1
if a1_f4 > a2_f4:
return 1



# All fields are equal
return 0

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

setup(
name='py-ard',
version='0.0.17',
version='0.0.18',
description="ARD reduction for HLA with python",
long_description=readme + '\n\n' + history,
author="CIBMTR",
Expand Down

0 comments on commit ecff778

Please sign in to comment.