cancel
Showing results for 
Search instead for 
Did you mean: 

SORT in PI

Former Member
0 Kudos

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

please help. much appreciated. thanks!

Accepted Solutions (1)

Accepted Solutions (1)

former_member190313
Active Participant
0 Kudos

Hi ,

try doing this using UDF.

Regards,

Sheetal

Answers (3)

Answers (3)

Former Member
0 Kudos

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

former_member472138
Active Contributor
0 Kudos

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
0 Kudos

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

Former Member
0 Kudos

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