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

Example

"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

"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?

Others

Example

Grouping is essentially mapping and should run faster than sorting

from question  

Sort by two columns, why not do grouping first?

What you describe in your question as grouping is more correctly described as sorting

from question  

Mysql-> Group after rand()

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

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?

I also propose manual sorting since i think manual sorting makes much more sense to grouping superclass together and make sure superclass are defined before subclassing -- otherwise your module won t even be importable

from question  

Vim: sort classes in a python source file

similar approach would be to to simply concatenate the arrays to strings banana banana-shake so that you didn t need a custom compare function any more and then split them after sorting to get back the original values;however your grouping method is superior to these approaches as your grouping method requires much less comparisons

from question  

Sorting by every nth element in javascript

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

And in case of how many times it is executed then bubble sort is executed up to o n 2 distribution sort grouping more than one sorting alghorithm but there is no sorting faster than ps if this comes from high school professor there is good chance he does not have full understanding of complexity theory either

from question  

What is the "Problem size" for bubble sort and distribution sort algorithm?

Will work as long as all your users are on the planet after making all the calculations use an array sorting method to find the x closest nodes to each node and there you have it you may or may not want to prevent a user being grouping on more than one grouping but that s just business logic actual code would be a little too much to provide at this time without seeing some of your progress first but this is basically what you need to do algoritmically

from question  

How to group objects based on longitude/latitude proximity using laravel/php

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

The second sorting condition i added breaks the tie should two aggregate_id grouping happen to have the same maximum update value;in this case the sort falls back to whichever grouping has the greater detection time to decide which comes first

from question  

Sort partitions with several criteria

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?

The first solution likely will be faster with smaller list of dicts since the sorting is easier but you would need to test that it is not required in the solution that i gave that the keys be grouping the keys is required for groupby to work

from question  

Create a dictionary from list of dictionary with multiple repeated keys and to select max value from that list

But my confusion is since i don t care about the order of name i should be able to do some kind of grouping which should be cheaper than sorting first and do sorting only on the numeric field

from question  

Sort by two columns, why not do grouping first?

For more day-to-day end users having canned reports that might be modified by the end user via a simple user interface that allows canned reports to modify restrictions grouping sorting is more useful

from question  

Custom user-driven reports on a known schema

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