Skip to content

Commit

Permalink
Version 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
goosepirate committed Jul 31, 2023
1 parent 8728e25 commit c41507b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="com.goosepirate.lox365.oxt" />
<icon><default xlink:href="icon.png" /></icon>
<version value="4.2" />
<version value="4.3" />
<publisher><name xlink:href="https://github.com/goosepirate/lox365" lang="en">goosepirate</name></publisher>
<display-name><name lang="en">Lox365</name></display-name>
<extension-description><src xlink:href="extension-description.txt" lang="en"/></extension-description>
Expand Down
5 changes: 4 additions & 1 deletion pythonpath/lox365.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ def SORT(array, sortIndex=1, sortOrder=1):
if sortOrder is None or sortOrder == 1: reverse = False
elif sortOrder == -1: reverse = True
else: return ValueError
stringify = True
if all(isinstance(item[sortIndex - 1], float) for item in array):
stringify = False
return tuple(sorted(array,
key=lambda r: str(r[sortIndex - 1]),
key=lambda r: str(r[sortIndex - 1]) if stringify else r[sortIndex - 1],
reverse=reverse))

def TEXTSPLIT(text, colDelimiter):
Expand Down
5 changes: 5 additions & 0 deletions pythonpath/test_lox365.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def test_SORT():
(('C', 1), ('B', 4), ('A', 3)),
) == (('A', 3), ('B', 4), ('C', 1))

'''Only numbers in array'''
assert SORT(
((3.0, 1), (2.4, 4), (4.1, 3), (1.1, 5)),
) == ((1.1, 5), (2.4, 4), (3.0, 1), (4.1, 3))

'''Multiple datatypes in array'''
assert SORT(
(('C', 1), ('B', 4), ('A', 3), (1, 5)),
Expand Down

0 comments on commit c41507b

Please sign in to comment.