Skip to content

Commit dcc4fae

Browse files
committed
Add docstring to sort_by method
1 parent f7827fc commit dcc4fae

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

QueryableList/Base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ def count(self):
178178

179179

180180
def sort_by(self, fieldName, reverse=False):
181+
'''
182+
sort_by - Return a copy of this collection, sorted by the given fieldName.
183+
184+
The fieldName is accessed the same way as other filtering, so it supports custom properties, etc.
185+
186+
@param fieldName <str> - The name of the field on which to sort by
187+
188+
@param reverse <bool> Default False - If True, list will be in reverse order.
189+
190+
@return <QueryableList> - A QueryableList of the same type with the elements sorted based on arguments.
191+
'''
181192
return self.__class__(
182193
sorted(self, key = lambda item : self._get_item_value(item, fieldName), reverse=reverse)
183194
)

0 commit comments

Comments
 (0)