AUNQSRT

=AUNQSRT(a,k)

a
required. array
k
-1 sort descending, 0 unique, 1 sort ascending

AUNQSRT sorts ascending, descending, or extracts unique values by rows of an array, left aligned.

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
837
Office Version
  1. 365
Platform
  1. Windows
AUNQSRT sorts ascending, descending, or extracts unique values by rows of an array, left aligned.

Excel Formula:
=LAMBDA(ar,k,
  LET(xk,OR(k={-1,0,1}),
    r,ROWS(ar),
    c,COLUMNS(ar),
    sr,SEQUENCE(r),
    s,SEQUENCE(r*c),
    q,QUOTIENT(s-1,c)+1,
    m,MOD(s-1,c)+1,
    a,INDEX(IF(ar="","",ar),q,m),
    x,a<>"",qf,FILTER(CHOOSE({1,2},q,a),x),
    y,SWITCH(k,-1,SORT(qf,{1,2},{1,-1}),0,UNIQUE(qf),1,SORT(qf,{1,2})),
    na,INDEX(y,,2),
    nq,INDEX(y,,1),
    fq,FREQUENCY(nq,sr),
    p,INDEX(fq,sr),
    nc,MAX(p),
    nsa,IF(p>=SEQUENCE(,nc),SEQUENCE(r,nc)),
    nsr,SMALL(nsa,SEQUENCE(SUM(p))),
    rs,IFNA(XLOOKUP(nsa,nsr,na),""),
    IF(xk,rs,"check var -1(desc),0(unique),1(asc)")
  )
)

LAMBDA 5.0.xlsx
ABCDEFGH
1a-1101ba
22-3cc20
3%dcdc3
4
5a-110b
62-3c0
7%dc3
8
9baa110-1
10cc220-3
11ddcc%3
12
13-1011aab
14-3022cc
153%ccdd
16
AUNQSRT post
Cell Formulas
RangeFormula
A5:E7A5=AUNQSRT(A1:G3,)
A9:G11A9=AUNQSRT(A1:G3,-1)
A13:G15A13=AUNQSRT(A1:G3,1)
Dynamic array formulas.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,216,505
Messages
6,131,026
Members
449,616
Latest member
PsychoCube

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top