Former Member

SORT in PI

Hi XI Gurus,

I have a problem regarding sorting again. Is there any way I can use sort but the characters after an "_" will not be part of the sorting?

EX.

test_1.0

variable_5.5

test_0.5

variable_0.1

expected output should be

test_1.0

test_0.5

variable_5.5

variable_0.1

what's happening in my mapping is

test_0.5

test_1.0

variable_0.1

variable_5.5

w/c is very wrong when mapped to the target fields.

I tried using substring first before I sort but I get this

test_1.0

test_5.5

variable_0.5

variable_0.1

10|10000 characters needed characters exceeded

May 26, 2011 at 05:59 AM

Hi ,

try doing this using UDF.

Regards,

Sheetal

10|10000 characters needed characters exceeded
• Former Member
May 26, 2011 at 06:22 AM

HI,

I think if you are getting values as

test_1.0

variable_5.5

test_0.5

variable_0.1

then use standard function Sort which is available in mapping.

Functions> Node Functions> Sort

double click sort function and select (Case sensitive and ascending)

and it will give output as

test_1.0

test_0.5

variable_5.5

variable_0.1

No need to use substring and other logic.

In mapping just use standard function Sort as following

Source field > sort> Target field

Thanks,

Bhupesh

10|10000 characters needed characters exceeded
• Former Member
May 26, 2011 at 07:22 AM

I asked a JAVA expert to create a UDF. thanks!

10|10000 characters needed characters exceeded
• Former Member

You can use this.

for (int i = 0; i < var1.length; i++) {

for (int j = i + 1; j < var1.length; j++) {

if ((var1[j]).compareTo(var1<i>) < 0) {

String temp = var1<i>;

var1<i> = var1[j];

var1[j] = temp;

}

}

}

return var1;

}

+++++++++++++++++++++++

May be your java expert can use this.

Edited by: Pothana Yadav on May 26, 2011 12:40 PM

• Former Member
May 26, 2011 at 06:39 AM

hi,

use the SORT function to sort the values and then use a UDF function to change to order of the sub-text.

i really don't see any other way

regards.

roi grosfeld