Aspects


vs


Grouping

The process of grouping entities into collections of associated elements.

Sorting

Sorting is the process of applying some order to a collection of items.

Application simpler fields

Quality Example
Better

"This way only a single int column needs to be sorted grouping which performs much better than sorting two text columns"

from question "How to solve performance GROUP BY issue in MySQL?"

Simpler

"Instead knowing that we want to grouping by these columns we can make the application code to do so simpler by sorting by these fields"

from question "Build mongoDB queries based on JSON from a user using Python"

Others

Quality Example
More efficient way

"Of course ordering could be forced obj.gettype .tostring and using lexical order but since a strict order is not necessary only grouping i was wondering if there s a more efficient way than sorting"

from question "Grouping elements of a list efficiently"

More optimal

"If the database is sophisticated enough adding an explicit order by clause will hint that sorting is more optimal for the grouping operation as well as the sorting can then be re-used in the query execution pipeline"

from question "Does ms access group by order the results?"

Looser

"Grouping has looser constraints than sorting so in theory it could be marginally faster than sorting but unless you re dealing with a lot of data you re unlikely to see a speed difference"

from question "Efficiently emulate SQL's group by clause in a programming language like Java or C++ instead of resorting to an RDBMS"

Less sense

"Your desired output does not reflect what you have as input if you want to grouping common sublists you can use itertools.groupby considering you want sorted output using a dict and then sorting makes less sense than just creating the grouping from the sorted list using groupby"

from question "Finding and grouping same values, (float vectors) in nested lists"

Faster

"The reason being that sorting less elements which the grouping generally produces is going to be faster than sorting all input documents"

from question "Is it possible to sort, group and limit efficiently in Mongo with a pipeline?"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0