F
F
forven2015-04-19 18:27:43
Algorithms
forven, 2015-04-19 18:27:43

What sorting algorithm to use to sort by price?

Sorting for search results by real estate listings database (date and price). In any case, the result will be ordered sections (since the prices are approximately equal and the date is also already normal). What algorithm to use?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
U
uvelichitel, 2015-04-19
@forven

The distribution in the sample is not random and predictable. They use it. You can first decompose into baskets (basket sort) or price order (radix sort). This will give a significant performance boost, if that's what you are interested in (up to linear n, against christomath n*log(n)). If you sort by date, then the selection will be partially ordered (and by the price you wrote) - on partially ordered arrays, simple insertion sort is the most effective. However, the newfangled TimSort built into Python and Java stdlib tries to use both optimizations.

A
Armenian Radio, 2015-04-19
@gbg

With such setting - any.

X
xmoonlight, 2015-04-19
@xmoonlight

Selective with priorities and grouping.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question