Alaska Software Inc. - asort
Username: Password:
AuthorTopic: asort
Salvatore Megna asort
on Mon, 17 Feb 2020 17:58:02 +0100
Hi,
is an asort with 2 conditions possible?

my array is exampe
{{"A", "19-02-2020", "13:00"},
{"B", "20-02-2020", "08:00"},
{"C", "20-02-2020", "13:00",
{"D", "19-02-2020", "08:00"}}

thanks
Regan CawkwellRe: asort
on Mon, 17 Feb 2020 17:32:01 +0000
On 17/02/2020 16:58, Salvatore Megna wrote:
> Hi,
> is an asort with 2 conditions possible?
> 
> my array is exampe
> {{"A", "19-02-2020", "13:00"},
> {"B", "20-02-2020", "08:00"},
> {"C", "20-02-2020", "13:00",
> {"D", "19-02-2020", "08:00"}}
> 
> thanks

You can pass a codeblock as the 3rd parameter of asort() to sort it however you want it. 
Check the docs for examples.

Those dates will need converting to dtos() type strings...

Regan
Rba
Tim CallahanRe: asort
on Mon, 17 Feb 2020 16:44:13 -0800
On Mon, 17 Feb 2020 17:58:02 +0100, Salvatore Megna
<smegna@tiscali.it> wrote:

>Hi,
>is an asort with 2 conditions possible?
>
>my array is exampe
>{{"A", "19-02-2020", "13:00"},
>{"B", "20-02-2020", "08:00"},
>{"C", "20-02-2020", "13:00",
>{"D", "19-02-2020", "08:00"}}
>
>thanks

To sort by date+time:

asort(aArray,,,{|x,y|DtosFormatt(x[2])+x[3]<DtosFormat(y[2])+y[3])

func DtosFormat(cDate)
return subs(cDate,7,4)+subs(cDate,4,2)+subs(cDate,1,2)