cancel
Showing results for 
Search instead for 
Did you mean: 

Sort snap's functionality

darshthakkar
Valued Contributor

Results of a sort snap (ascending) is a little bit hard to digest. I used a file reader which was reading a single column A (i.e. IDs) and I decided to sort it. The results I get are surprising.

Input raw data:
1217
151983
1543
370904
402
402783
901602
373
373916
374
120651
1216
1000022
1000027
394533
906
909
1000019
918
1205

Output after sort:
1000019
1000022
1000027
1205
120651
1216
1217
151983
1543
370904
373
373916
374
394533
402
402783
901602
906
909
918

Result expected:
373
374
402
906
909
918
1205
1216
1217
1543
120651
151983
370904
373916
394533
402783
901602
1000019
1000022
1000027

Can anyone explain what’s the rationale behind the results I got using the sort snap? It’s confusing for me to be honest.
Thanking you in advance for your time, help and response.

Regards,
Darsh

1 ACCEPTED SOLUTION

bojanvelevski
Valued Contributor

Hey @darshthakkar,

This happens because the field you’re sorting is string, so it is sorted alphabetically.

As I can see, all of these values support parsing so try and parse them before sorting.

Ex. : parseInt($ID)

View solution in original post

8 REPLIES 8

Absolutely, thanks @bojanvelevski for your suggestions.
I did exactly what you said, first being, putting parseInt($ID) in the expression within the maper and second being, changing the data type of column (ID) to number in the excel itself (with sort ascending).

While you were referring to “Cell formatting”, did you mean to change this under the preview that gets generated? Snap below for your reference:
image

bojanvelevski
Valued Contributor

I apologize, I was confused with a different use case 🙂 Parsing the column so you could have a successful sorting is the right way. There’s no need for further adjustments or trying a different approaches.

No worries, thank you for your confirmation.

@bojanvelevski: I got your point on formatted, I believe you were referring to the one below:

image

That option is available in excel parser snap itself.
I will keep this in mind and test it standalone, without interfering with my current scenario. Thanks again, your help is much appreciated.