LazySorted : A Lazily, Partially Sorted Python List
LazySorted is a Python C extension implementing a partially and lazily sorted list data structure. It solves a common problem faced by programmers, in which they need just part of a sorted list, like its middle element (the median), but sort the entire list to get it. LazySorted presents them with t...
Saved in:
| Published in | Journal of statistical software Vol. 65; no. Code Snippet 1; pp. 1 - 10 |
|---|---|
| Main Author | |
| Format | Journal Article |
| Language | English |
| Published |
Foundation for Open Access Statistics
01.05.2015
|
| Online Access | Get full text |
| ISSN | 1548-7660 1548-7660 |
| DOI | 10.18637/jss.v065.c01 |
Cover
| Summary: | LazySorted is a Python C extension implementing a partially and lazily sorted list data structure. It solves a common problem faced by programmers, in which they need just part of a sorted list, like its middle element (the median), but sort the entire list to get it. LazySorted presents them with the abstraction that they are working with a fully sorted list, while actually only sorting the list partially with quicksort partitions to return the requested sub-elements. This enables programmers to use naive "sort first" algorithms but nonetheless attain linear run-times when possible. LazySorted may serve as a drop-in replacement for the built-in sorted function in most cases, and can sometimes achieve run-times more than 7 times faster. |
|---|---|
| ISSN: | 1548-7660 1548-7660 |
| DOI: | 10.18637/jss.v065.c01 |