Skip to content

Commit

Permalink
Fix ascending and descending sorting (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinuax authored Dec 29, 2023
1 parent 8f44e79 commit 3c65b72
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rolabesti/sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This module contains all the supported sortings and the sort function.
"""

from operator import itemgetter
import random

SORTINGS = ('asc', 'desc', 'random')
Expand All @@ -14,8 +15,8 @@
def sort(tracks, sorting):
"""Return tracks sorted by sorting type."""
if sorting == 'asc':
return tracks
return sorted(tracks, key=itemgetter('path'))
elif sorting == 'desc':
return list(reversed(tracks))
return sorted(tracks, key=itemgetter('path'), reverse=True)
else:
return random.sample(tracks, len(tracks))

0 comments on commit 3c65b72

Please sign in to comment.