Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Er, are you aware of the C++ standard library's std::nth_element() function? (Even my "pure C" programs tend to be compiled with g++ to gain access to that and std::sort().)


Yes, this is exactly what the author is trying to port to Python.

Mandatory reference link: http://en.cppreference.com/w/cpp/algorithm/nth_element . Note linear complexity.

There's also std::partial_sort:

http://en.cppreference.com/w/cpp/algorithm/partial_sort




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: