none
Unexpected behavior with SortList? RRS feed

  • Question

  • I would like to sort multiple student objects based on EmployeeID attribute received from a lookup query.

    Examples:

    LookUp query example: KEY=StudentAccount    /Person[(EmployeeType=’Student’)]

    SortList([//Queries/Object]) is giving expected results, but SortList([//Queries/Object/Attribute]) gives a list without sorting it.

     

    SortList([//Queries/StudentAccount]) Sorts all student objects according to display name

    SortList([//Queries/StudentAccount/EmployeeID]) Does not sort at all.

    Ok, so the EmployeeID is not a multi valued attribute and cannot be sorted, sound logical.

    Try 2

    [//Queries/StudentAccount/EmployeeID] => [//WorkflowData/EmployeeID]

    I now have a WorkflowData with multiple string objects containing EmployeeID.

     

    SortList([//WorkflowData/EmployeeID]) gives an empty result.

    Should SortList sort my WorkflowData or am I doing it wrong?

     

    Best regards

    Joakim 
    Tuesday, September 26, 2017 4:05 PM

Answers

All replies

  • "SortList([//Queries/StudentAccount/EmployeeID]) Does not sort at all." - It should be sorted based on the datatype EmployeeID is of (i.e. string). So  1, 10, 2, 20, 200, 3 is the correct sort order if that is what you are seeing :)

    For WorkflowData producing empty result, check Variables wiki.

    Tuesday, September 26, 2017 5:17 PM
    Owner
  • Noted, with thanks. 

    I still can’t understand why I am not able to sort the objects.

    Last(SortList([//Queries/StudentAccount/EmployeeID])) and Last([//Queries/StudentAccount/EmployeeID]) gives the same object.
    EmployeeID= "123456F313"

    Testing in Powershell gives these results: (apologies for the long text.)

    Unsorted:
    PS C:\Windows\system32> (Search-Resources -XPath  "/Person[(EmployeeType='Student')and(contains(EmployeeID,'123456F'))]" -AttributesToGet EmployeeID).EmployeeID
    123456F318
    123456F352
    123456F077
    123456F313

    Sorted:
    PS C:\Windows\system32> (Search-Resources -XPath  "/Person[(EmployeeType='Student')and(contains(EmployeeID,'123456F'))]" -AttributesToGet EmployeeID -SortAttributes EmployeeID).EmployeeID
    123456F077
    123456F313
    123456F318
    123456F352

    Best regards
    Joakim



    • Edited by di99dajo Friday, September 29, 2017 6:42 AM
    Wednesday, September 27, 2017 8:20 AM
  • Oh,

    First(SortList([//Queries/StudentAccount/EmployeeID])) and First([//Queries/StudentAccount/EmployeeID]) also gives the same object, but not the same as Last().
    First() gives EmployeeID= "123456F318"

    Best regards
    Joakim

    Wednesday, September 27, 2017 8:26 AM
  • LOL :) I just made new MIMWAL release. MIMWAL v2.17.0927.0

    Thanks for detailed repro!!

    • Marked as answer by di99dajo Wednesday, September 27, 2017 3:24 PM
    Wednesday, September 27, 2017 9:27 AM
    Owner
  • Hi,

    Tested and it work well now.

    Many thanks.

    Best regards

    Joakim

    Wednesday, September 27, 2017 3:25 PM