You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-46Lines changed: 25 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,45 +56,35 @@ Sort rows_dict by _grade_, descending, then _attend_, ascending and put None fir
56
56
```
57
57
from multisort import multisort
58
58
rows_sorted = multisort(rows_dict, [
59
-
('grade', {'reverse': False})
60
-
,'attend'
59
+
('grade', reverse=False),
60
+
('attend')
61
61
])
62
62
63
63
```
64
64
Sort rows_dict by _grade_, descending, then _attend_ and call upper() for _grade_:
65
65
```
66
66
from multisort import multisort
67
67
rows_sorted = multisort(rows_dict, [
68
-
('grade', {'reverse': False, 'clean': lambda s: None if s is None else s.upper()})
69
-
,'attend'
68
+
mscol('grade', 'reverse'=False, clean=lambda s: None if s is None else s.upper()),
69
+
('attend')
70
70
])
71
71
72
72
```
73
73
`multisort` parameters:
74
74
option|dtype|description
75
75
---|---|---
76
-
`key`|int or str|Key to access data. int for tuple or list
77
-
`spec`|str, int, list|Sort specification. Can be as simple as a column key / index
76
+
`rows`|int or str|Key to access data. int for tuple or list
77
+
`spec`|str, int, list|Sort specification. Can be as simple as a column key / index or `mscol`
78
78
`reverse`|bool|Reverse order of final sort (defalt = False)
79
79
80
-
`multisort``spec` options:
80
+
`multisort` spec options:
81
81
option|dtype|description
82
82
---|---|---
83
-
reverse|bool|Reverse sort of column
84
-
clean|func|Function / lambda to clean the value. These calls can cause a significant slowdown.
85
-
required|bool|Default True. If false, will substitute None or default if key not found (not applicable for list or tuple rows)
86
-
default|any|Value to substitute if required==False and key does not exist or None is found. Can be used to achive similar functionality to pandas `na_position`
87
-
88
-
89
-
90
-
### `sorted` with `reversor`
91
-
Sort rows_dict by _grade_, descending, then _attend_ and call upper() for _grade_:
92
-
```
93
-
rows_sorted = sorted(rows_dict, key=lambda o: (
94
-
reversor(None if o['grade'] is None else o['grade'].upper())
95
-
,o['attend'])
96
-
))
97
-
```
83
+
`key`|int or str|Key to access data. int for tuple or list
84
+
`reverse`|bool|Reverse sort of column
85
+
`clean`|func|Function / lambda to clean the value. These calls can cause a significant slowdown.
86
+
`required`|bool|Default True. If false, will substitute None or default if key not found (not applicable for list or tuple rows)
87
+
`default`|any|Value to substitute if required==False and key does not exist or None is found. Can be used to achive similar functionality to pandas `na_position`
0 commit comments