用昂贵的比较排序? [英] sorting with expensive compares?

查看:71
本文介绍了用昂贵的比较排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



大家好。


Python似乎有一个很好的排序方法,但在排序数组元素时

是非常大,因此有非常昂贵的比较,是否有一些已经可用的排序功能,将像元素合并到

a链中,这样他们就赢了''必须多次重新比较?


谢谢!


Hi folks.

Python appears to have a good sort method, but when sorting array elements
that are very large, and hence have very expensive compares, is there some
sort of already-available sort function that will merge like elements into
a chain, so that they won''t have to be recompared as many times?

Thanks!

推荐答案



Dan Stromberg写道:

Dan Stromberg wrote:
嗨伙计们。

Python似乎有一个很好的排序方法,但在排序数组元素时非常大,因此有非常昂贵的比较,是否有一些已经可用的排序功能,将元素合并到链中,这样他们就不必再多次重新比较?

谢谢!
Hi folks.

Python appears to have a good sort method, but when sorting array elements
that are very large, and hence have very expensive compares, is there some
sort of already-available sort function that will merge like elements into
a chain, so that they won''t have to be recompared as many times?

Thanks!




可能更容易记住cmp(),查看在线食谱或

喜欢这个装饰者

http://mail.python.org/pipermail/pyt...er/303035.html
http://aspn.activestate.com/ASPN/Python/Cookbook/



might be simpler to memoize cmp(), look in online cookbook or
something like this decorator

http://mail.python.org/pipermail/pyt...er/303035.html
http://aspn.activestate.com/ASPN/Python/Cookbook/




Dan Stromberg写道:

Dan Stromberg wrote:
嗨伙计。

Python似乎有一个很好的排序方法,但在排序数组元素时
这是非常大的,因此有非常昂贵的比较,是否有一些已经可用的排序功能,将元素合并到一个链,这样他们就不必重新比较多次?

谢谢!
Hi folks.

Python appears to have a good sort method, but when sorting array elements
that are very large, and hence have very expensive compares, is there some
sort of already-available sort function that will merge like elements into
a chain, so that they won''t have to be recompared as many times?

Thanks!



听起来像DSU时间。


[a] - > [(hash(a),a)]


Sounds like DSU time.

[a] -> [ (hash(a), a) ]



bo **** @ gmail.com 写道:
Dan Stromberg写道:
Dan Stromberg wrote:
嗨伙计。

Python似乎有一个很好的排序方法,但是当排序非常大的数组元素,因此有非常昂贵的比较时,是否有一些已经可用的排序函数将类似元素合并到
链条,这样他们就不必多次重新比较了吗?

谢谢!
Hi folks.

Python appears to have a good sort method, but when sorting array elements
that are very large, and hence have very expensive compares, is there some
sort of already-available sort function that will merge like elements into
a chain, so that they won''t have to be recompared as many times?

Thanks!


听起来像DSU时间。

[a] - > [(hash(a),a)]


Sounds like DSU time.

[a] -> [ (hash(a), a) ]




啊哈!或者:记录数组,例如log base 10或其他一些

单调变换和排列顺序索引
http://aspn.activestate.com/ASPN/Coo.../Recipe/306862



Aha! OR: take a log of the array, e.g. log base 10 or some other
monotonic transform and permutation order indexes
http://aspn.activestate.com/ASPN/Coo.../Recipe/306862


这篇关于用昂贵的比较排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆