Mon Aug 15, 2022 8:58 am
Login Register Lost Password? Contact Us

Please Note: The HPCC Systems forums are moving to Stack Overflow. We invite you to post your questions on Stack Overflow utilizing the tag hpcc-ecl ( This legacy forum will be active and monitored during our transition to Stack Overflow but will become read only beginning September 1, 2022.

Sort on Enum Values

Comments and questions related to the Enterprise Control Language

Wed Apr 21, 2021 8:49 am Change Time Zone

Hi ALL ,
In case have to sort on enum values rather the column values as need is in specific order
and which has to be consistent and in control rather to be dependent on data.
Is there a way to sort

MyRec := {STRING3 Value1,STRING3 Category1, STRING3 Category2};
SomeFile := DATASET([{'NVS','T','ABC'},{'NVS','C','ABC'},{'A','X','BAC'},

srtvalues := enum(unsigned1,AAA, ABC, BAC,AAC,PQR);
//need to sort on values of 3rd field which is static but can add latter
Srtd_values_ds := sort(SomeFile,srtvalues.AAA);
Posts: 29
Joined: Fri Feb 23, 2018 8:30 am

Wed Apr 21, 2021 1:10 pm Change Time Zone

You could just PROJECT (or Vertical Slice TABLE) to add / replace the ENUM values with specific integers say, then, with output from this PROJECT sort on that integer?

Actually the ref manual says:
A comma-delimited list of expressions or key fields.
So 'expression' could be the return from a DICTIONARY lookup that converts ENUM to a required sort order?
Posts: 444
Joined: Sat Oct 01, 2011 7:26 pm

Wed Apr 21, 2021 2:40 pm Change Time Zone

Code: Select all
ds := DATASET([{'Payload1','ABA'}
              ],{STRING payload,STRING3 Itm});
Codes := DATASET([{'ABA' ,3 },
                   {'BBB' ,2 },
                   {'AAA' ,1 },
                   {'BBA' ,0 }], {STRING code,UNSIGNED1 sortPosition});

Lokup := DICTIONARY(Codes,{code => sortPosition});

Posts: 444
Joined: Sat Oct 01, 2011 7:26 pm

Return to ECL

Who is online

Users browsing this forum: No registered users and 2 guests