Sort utils
tablite.sort_utils
Attributes
tablite.sort_utils.uca_collator = Collator()
module-attribute
tablite.sort_utils.modes = {'alphanumeric': text_sort, 'unix': unix_sort, 'excel': excel_sort}
module-attribute
Classes
tablite.sort_utils.HashDict
Bases: dict
This class is just a nicity syntatic sugar for debugging. Function identically to regular dictionary, just uses tupled key.
Functions
tablite.sort_utils.HashDict.items()
Source code in tablite/sort_utils.py
277 278 |
|
tablite.sort_utils.HashDict.keys()
Source code in tablite/sort_utils.py
280 281 |
|
tablite.sort_utils.HashDict.__iter__() -> Iterator
Source code in tablite/sort_utils.py
283 284 |
|
tablite.sort_utils.HashDict.__getitem__(key)
Source code in tablite/sort_utils.py
286 287 |
|
tablite.sort_utils.HashDict.__setitem__(key, value)
Source code in tablite/sort_utils.py
289 290 |
|
tablite.sort_utils.HashDict.__contains__(key) -> bool
Source code in tablite/sort_utils.py
292 293 |
|
tablite.sort_utils.HashDict.__delitem__(key)
Source code in tablite/sort_utils.py
295 296 |
|
tablite.sort_utils.HashDict.__repr__() -> str
Source code in tablite/sort_utils.py
298 299 |
|
tablite.sort_utils.HashDict.__str__() -> str
Source code in tablite/sort_utils.py
301 302 |
|
Functions
tablite.sort_utils.text_sort(values, reverse=False)
Sorts everything as text.
Source code in tablite/sort_utils.py
135 136 137 138 139 140 141 142 143 |
|
tablite.sort_utils.unix_sort(values, reverse=False)
Unix sortation sorts by the following order:
| rank | type | value | +------+-----------+--------------------------------------------+ | 0 | None | floating point -infinite | | 1 | bool | 0 as False, 1 as True | | 2 | int | as numeric value | | 2 | float | as numeric value | | 3 | time | τ * seconds into the day / (24 * 60 * 60) | | 4 | date | as integer days since 1970/1/1 | | 5 | datetime | as float using date (int) + time (decimal) | | 6 | timedelta | as float using date (int) + time (decimal) | | 7 | str | using unicode | +------+-----------+--------------------------------------------+
τ = 2 * π
Source code in tablite/sort_utils.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
tablite.sort_utils.excel_sort(values, reverse=False)
Excel sortation sorts by the following order:
| rank | type | value | +------+-----------+--------------------------------------------+ | 1 | int | as numeric value | | 1 | float | as numeric value | | 1 | time | as seconds into the day / (24 * 60 * 60) | | 1 | date | as integer days since 1900/1/1 | | 1 | datetime | as float using date (int) + time (decimal) | | (1)*| timedelta | as float using date (int) + time (decimal) | | 2 | str | using unicode | | 3 | bool | 0 as False, 1 as True | | 4 | None | floating point infinite. | +------+-----------+--------------------------------------------+
- Excel doesn't have timedelta.
Source code in tablite/sort_utils.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
tablite.sort_utils.rank(values, reverse, mode)
values: list of values to sort. reverse: bool mode: as 'text', as 'numeric' or as 'excel' return: dict: d[value] = rank
Source code in tablite/sort_utils.py
254 255 256 257 258 259 260 261 262 263 264 |
|