Is `sort_unstable_by_key` generally faster than `sort_by_key`?

⚓ Rust    📅 2025-07-27    👤 surdeus    👁️ 12      

surdeus

Warning

This post was published 129 days ago. The information described in this article may have changed.

The documentation says that unstable algorithm have O(n * log(n)) complexity and doesn't allocate, as opposed to the stable algorithm with O(m * n * log(n)) complexity and allocations.

At first glace, the unstable algorithm seems better in every way, is there a catch to that? (other than the order of equal items not being preserved, which I don't care about)

3 posts - 3 participants

Read full topic

🏷️ Rust_feed