This discussion is archived
4 Replies Latest reply: Jan 27, 2013 4:09 AM by Hjava RSS

space and sorting ?

Hjava Newbie
Currently Being Moderated
I have the following string &mystring=test8@gmail.com; test13@gmail.com; test5@gmail.com; test8@gmail.com; test7@gmail.com; test8@gmail.com;
Local array of string &array_string = Split(&mystring, ";");

&array_string.Sort("A");
it become test5@gmail.com-> test7@gmail.com-> test8@gmail.com->test13@gmail.com->test8@gmail.com->test8@gmail.com
why not test5@gmail.com-> test7@gmail.com-> test8@gmail.com->test8@gmail.com->test8@gmail.com->test13@gmail.com
  • 1. Re: space and sorting ?
    Michel Journeyer
    Currently Being Moderated
    Because your sort order is probably set to binary (PeopleTools options page). From the PeopleBooks:
    The type of sort done by this function, that is, whether it is a linguistic or binary sort, is determined by the Sort Order Option on the PeopleTools Options page.
  • 2. Re: space and sorting ?
    Hjava Newbie
    Currently Being Moderated
    on PeopleTools > Personalization > Personalization Options can see the sorting setting
  • 3. Re: space and sorting ?
    GrahamSmith Oracle ACE Director
    Currently Being Moderated
    you are sorting an array of strings. Therefore, the sort will be done based on the ASCII character code. Alpha and numeric characters are handled in the same way. The ascii character code for 1 = 49 and for 8 = 56.

    So, in your example test13@gmail.com->test8@gmail.com becuase the number 49 naturally comes before 56. in sorting strings no differentiation is made between alpha and numeric characters.

    imagine you were sorting the following strings. What would you want the sort behaviour to be? Logically an ascii based sort would produce a sort order that may not match what a human might illogically want.

    test4x1
    test1x3
    test2xx2

    To my knowledge... there is no way to control the behaviour of this kind of sorting in PeopleTools.

    There may be a way to break out of PeopleCode and do a sort in Java. http://stackoverflow.com/questions/104599/sort-on-a-string-that-may-contain-a-number

    Good luck
    Graham
  • 4. Re: space and sorting ?
    Hjava Newbie
    Currently Being Moderated
    Thanks for the reply,
    I just may sure there is not space between my sorting string to deal with the problem. my questions is why??
    in ASCII space is 32 letter is 65 to 90 and 97 to 122, how come the space can cause the sorting problem???

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points