Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76495
| X-Received | by 10.236.17.234 with SMTP id j70mr15632268yhj.26.1408382300956; Mon, 18 Aug 2014 10:18:20 -0700 (PDT) |
|---|---|
| X-Received | by 10.50.79.201 with SMTP id l9mr11672igx.5.1408382300816; Mon, 18 Aug 2014 10:18:20 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!m5no907560qaj.0!news-out.google.com!aw9ni1931igc.0!nntp.google.com!r2no2322288igi.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Mon, 18 Aug 2014 10:18:20 -0700 (PDT) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=140.113.69.236; posting-account=eLmTSwoAAAA5GT-zoD7dCLRZUnwvEDUD |
| NNTP-Posting-Host | 140.113.69.236 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <51dfbe9b-f6e0-4532-bc2d-e7ce2fc282b5@googlegroups.com> (permalink) |
| Subject | efficient partial sort in Python ? |
| From | Chiu Hsiang Hsu <wdv4758h@gmail.com> |
| Injection-Date | Mon, 18 Aug 2014 17:18:20 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:76495 |
Show key headers only | View raw
I know that Python use Timsort as default sorting algorithm and it is efficient, but I just wanna have a partial sorting (n-largest/smallest elements). In the current state, I can only find this kind of functions from heapq, but it's too slow for this problem, the pure c sorted function can easily beat heapq.nlargest even though it sort all the elements. I think it would be better if we have an effeicient partial sorting function, maybe it could be like this : partial_sorted(data, n), data.partial_sort(n) Does anyone have any more information for partial sorting ? Btw, C++ has a partial_sort function in <algorithm>, but I don't know what algorithm it really use.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
efficient partial sort in Python ? Chiu Hsiang Hsu <wdv4758h@gmail.com> - 2014-08-18 10:18 -0700
Re: efficient partial sort in Python ? Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-18 12:48 -0600
Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-18 14:42 -0700
Re: efficient partial sort in Python ? Chiu Hsiang Hsu <wdv4758h@gmail.com> - 2014-08-19 12:37 -0700
Re: efficient partial sort in Python ? Terry Reedy <tjreedy@udel.edu> - 2014-08-19 18:11 -0400
Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:05 -0700
Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:10 -0700
Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:22 -0700
Re: efficient partial sort in Python ? Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-19 18:00 -0600
csiph-web