cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting of knots

Former Member
0 Kudos

Hello Forum

I have a structure similar to that:

<ITEM>

<KEY>3</KEY>

<VALUE>sth1</VALUE>

</ITEM>

<ITEM>

<KEY>7</KEY>

<VALUE>sth1</VALUE>

</ITEM>

<ITEM>

<KEY>1</KEY>

<VALUE>sth1</VALUE>

</ITEM>

<ITEM>

<KEY>2</KEY>

<VALUE>sth1</VALUE>

</ITEM>

Now I would like to sort the knots by the KEY value. Is there any possibility to do that with the standard sort functions?

Thanks in advance for any comments.

Regards

Christian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christian,

Try this:

Key -->removeContext --> sort --> splitByValue(eachValue) --> Target field

Value --> removeContext --> sortByKey( To second argument) --> splitByValue(eachValue) --> Target field

To the first argument of 'sortByKey' join the field 'Key'.

-Tanaya.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello Tanaya

Thanks a lot, that was it.

I thought, that there must be a more simple way, that you can just sort the <ITEM>s, but this way is also okay, as I only have six values to sort...

Regards

Christian

former_member187339
Active Contributor
0 Kudos

Hi Christian,

Have you tried like this

Key>mapwithDefault>removecontext>sortbykey->splitbyValue-->targetfield

Value>mapwithDefault>removecontext-->

If you are not successful be sortbykey there is no other standard node function to do this, you need to write a udf,,..

Regards

Suraj

Former Member
0 Kudos

Hello Suraj

this also does not seem to work. I think I will do some programming now ) Anyway thank you for your answers...

Regards

Christian

Former Member
0 Kudos

Hi Chirstian,

Use node function Sortbykey.

Key->RemoveContext->Sortbykey-->key.

Regards,

Sateesh

Former Member
0 Kudos

I just tried that, but it seems that there is no possibility to use the sortbykey function just on the <ITEM>s and have all data under them sorted, right?!

Or do I have to sort all values below the <ITEM>?

Edited by: Christian Schroeder on Dec 15, 2009 12:45 PM

former_member187339
Active Contributor
0 Kudos

Hi Christian,

Two approaches are there:

1. Use standard node function sortbykey

2. use udf

Regards

Suraj

Former Member
0 Kudos

I tried the first one using SortByKey on the <ITEM> s using the KEY-Value as sortkey, but this seems not to work. If you say, that there is no way to do this using standard node functions then its okay and I have to go further using UDFs...