A Random Sort Using SORT and RANDARRAY
August 15, 2022 - by Bill Jelen
![A Random Sort Using SORT and RANDARRAY A Random Sort Using SORT and RANDARRAY](/img/excel-tips/2022/08/a-random-sort-using-sort-and-randarray.jpg)
Difficult scenarios like random drug testing and random with no repeats become mind-numbingly simple when you combine SORT
with RANDARRAY
.
Say that you want to sort 13 names randomly and without repeats. To do this, you use =SORTBY(A4:A16,RANDARRAY(13))
, as shown below.
![To randomly sort for a drug test, use =SORTBY(A4:A16, but then specify RANDARRAY(13) as the by_array argument.](/img/content/2022/08/excel-sort-with-a-formula-using-sort-and-sortby-11.jpg)
The SORTBY function's syntax is =SORTBY(array, by_array1, sort_order1,)...
![The syntax of SORTBY is array, by array, sort order, .... The first two arguments are required. You can repeat by_array1 and sort_order1 up to 126 times.](/img/content/2022/08/excel-sort-with-a-formula-using-sort-and-sortby-09.jpg)
Say that you want to sort by team and then score, and you want to show only the names. In this case, you can use SORTBY
as shown here.
![The original data has name, team, score. This formula sorts by team and score, but only gives you the names. =SORTBY(A4:A16,B4:16,1,C4:C16,-1).](/img/content/2022/08/excel-sort-with-a-formula-using-sort-and-sortby-10.jpg)
This article is an excerpt from Power Excel With MrExcel
Title photo by Alex Block on Unsplash