Cyker Way <[email protected]> added the comment:
As for performance, I think both single-pass and multi-pass sorts have
worst-case time complexity `m * n * log(n)`, assuming the number of items is
`n` and each item has dimension `m`. Whichever is faster seems to be
data-dependent. So I made a more comprehensive performance evaluation in
`performance-1.py`. It turns out either single-pass or multi-pass can be
80-100% faster than the other, on different inputs.
Since single-pass and multi-pass sorts are good at different inputs and there
is currently no statistics on real application data supporting either, both
look OK to me. But I hope you can add something in the interface of sorting
functions (mainly `sorted` and `list.sort`) so that users don't have to write
that multi-pass sort again and again. If the `keyspec` format is deemed too
complicated, `keys` and `reverses` also look good to me:
sorted(items, keys=(key0, key1, key2), reverses=(True, False, True))
And you are free to use whatever sorting algorithms in its implementation for
this kind of task.
----------
Added file: https://bugs.python.org/file47877/performance-1.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35010>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com