7 ms·
> E.g.: maybe don't output results reliant on a HashSet order - sort them. I would much prefer shuffling them in that case. Less expensive and reduces the size
by kqr 5y ago
> E.g.: maybe don't output results reliant on a HashSet order - sort them.
I would much prefer shuffling them in that case. Less expensive and reduces the size of the public API. (Returning items in a specific order, whichever it is, still is a sort of promise.)
- silvestrov 5y agoOne gotcha is that some SQL databases automatically sort items when you do a GROUP BY. Then a few releases later the database switches from a B-tree to a hashmap for the GROUP BY internals and now your output is no longer sorted.