I have an excel file that holds a column with data in numbers, when I try to sort it, it's sorted like this:
original list:
1,99,1011,33122,4589,330
sorted now:
1,1011,330,33122,4589,99
need to be sorted like this:
1,99,330,1011,4589,33122
How can I do that?
Select a single cell from the column you want to sort.
On the Data tab, in the Sort and filter group, click. to rank in ascending order (from A to Z or from the smallest to the largest number).
Click on. to sort in descending order (from Z to A or from the largest to the smallest number).
Related
I have a list of cells which contain values (A,B,C,D,E...). I'd like to count the largest duplicate.
I think about multiple MAX together with COUNTIF but that would be very long since my list of value has 60+ items
Example file: https://docs.google.com/spreadsheets/d/1ZUnSokdPsEPVJw9S8DfGHvJE1L1Ng8litbCXeA9QWzI/edit?usp=sharing
I'm new at this, but I think the following formula does what you've asked.
=INDEX(A2:G2,MODE(MATCH(A2:G2,A2:G2,0)))
Your sheet is view only, so I can't place it there.
Replace my A2:G2 range in the formula with the range with your long list (either column or row) of values.
This will search the range for the amount of the most duplicates, and return the first value that is duplicated the most.
Note: it doesn't flag if there are other values that have an equal number of duplciates as the first value.
Here is a sample sheet, with examples using values in a row, or in a column:
https://docs.google.com/spreadsheets/d/1mIxTKXjED9kpqAGV55pf8Yjq102Sc5Ymn_yY6qh3XmE/edit?usp=sharing
Let me know if this doesn't achieve what you want.
I wanted to use Google Sheets to do a competition ranking which can help me to rank or sort the ranking automatically when I key in the Points.
However, there is a condition where there will be a tied happens. If a tie happens, I will take the Score Differences (SD) into consideration. If the Score Differences is low, then it will be rank higher in the tie condition.
See below table for illustration:
For example: Currently Team A and Team D having the highest PTS, so both of them are currently Rank 1. However, Team D is having a lower SD compare to Team A. So I wanted to have it automatically rank Team D as Rank 1 and Team A as Rank 2.
Is this possible?
One solution might be to create a hidden column with a formula like:
=PTS * 10000 - SD
(Replacing PTS and SD with the actual cell references)
Multiplying PTS by 10000 ensures it has a higher priority than SD.
We want to reward low SDs, so we subtract instead of add.
Finally, in the rank column, we can use a formula like:
=RANK(HiddenScoreCell, HiddenScoreColumnRange, 0)
So, for example, if the HiddenScore column is column K, the actual formula for row 2 might look like
=RANK(K2, K:K, 0)
The third parameter is 0 as we want higher scores to have a lower rank.
To sort, you can just apply a sort on the Rank column.
With sort() you can define multiple sorting criteria (see [documentation][1], e.g.
=sort(A2:I5,8,false,7,false)
So you're going to sort your table (in A2:I5, change accordingly) based first on PTS, descending, then on SD, descending? You can add more criteria with more pairs of parameters (column index, then descending or ascending as a boolean).
Then you need to compare your team name with with the sorted table and find its rank in the sorted list:
=ArrayFormula(match(A2:I5,sort(A2:I5,8,false,7,false),0))
Paste that formula in I2 (assuming your table starts in A1 with its headers, otherwise adjust accordingly).
=ARRAYFORMULA(IF(LEN(A2:A), RANK(H2:H*9^9-G2:G, H2:H*9^9-G2:G), ))
Assume that we have an Mystery-Sort(A), which takes an array A of
length n as input, sorts the numbers in A in non-decreasing order, and returns the sorted array.
We do not know whether the algorithm implemented by Mystery-Sort is stable.
I need a procedure that takes an array of n integers and returns the sorted array in non-decreasing order, but i need the procedure to be stable.
How can i achieve this the pseudo-code of a stable sorting procedure Stable-Sort(A), which pre-processes and/or postprocesses
the elements in A in O(n) time, makes only one call to Mystery-Sort, and returns
the sorted array in non-decreasing order.
I see this as coming in two phases: a pre-processing phase in which you find all duplicated elements with their identifiers; a post-processing phase where you simply overwrite the found elements into their original order.
You didn't specify how you can differentiate elements that sort as the same value; I'll call that the id. In this first pass, construct a table with one row per value. Iterate through the array; store the id of each element (or the entire element) in the matching table row in the table. If there's already an element there, extend that row and store the current element.
At this point, if you wish, you can eliminate any row of the table with fewer than 2 elements.
For the post-procesing, iterate through the sorted array. If the value you find is in the table, then don't trust the order returned from Mystery-Sort. Instead, simply overwrite the next elements with the ones from that row of the table. This restores their original order.
When you reach the end of the sorted list, you're done.
I have a matrix (n*n) which all its columns are ordered in non descending order while the rows are not ordered - I know that each value in a row is smaller than all the values in the rows below, but the values inside the rows are not sorted, although they are all either smaller or identical to the values in the row below.
I need to find a value in this matrix in O(n). I thought of running a binary search on one of the columns until I get into one cell which is the closest one to my searched value (in case, of course, I did not find the value during the search).
Then, I will check for the searched value in the row of the cell and in the row above (if cell > searched_val) or the row below (if cell < searched_val).
Will it work? Will it also work in case that the column is full with identical values?
I know that each value in a row is smaller than all the values in the rows below
This means that the rows are ordered in ascending order
So, starting from your definition, both rows and columns are ordered.
In this way you can search your Matrix as an array of size n*n. Binary search in this case will go:
O(log(n*n)) = O(2*log(n)) = O(log(n)) < O(n)
You just have to define an index that moves in the Matrix in ascending (or descending) order.
I have a number of distinct elements in an array and want to find those items first before sorting the array. I was thinking of using a hash table to find the elements, but is that possible since I then have to access the table to get the elements again? Am I on the right track?