Change row arrangement from a given pattern to another i.e. change row index

I have data in the following format.
|EXPORT|AUD|53.44|
|EXPORT|EURO|89.56|
|EXPORT|GBP|104.6|
|EXPORT|SGD|61.14|
|EXPORT|USD|82.61|

but i need it in a format:
|EXPORT|USD|82.61|
|EXPORT|GBP|104.6|
|EXPORT|EURO|89.56|
|EXPORT|SGD|61.14|
|EXPORT|AUD|53.44|

that is USD in first row, GBP in second… etc

@pritha.purkait,

You can sort the datatable by currency but it will be A-Z or Z-A no custom logics.

What’s the logic by the way and how many conditions do you have?

Thanks,
Ashok :slight_smile:

@ashokkarale actually there’s no logic as such. This is basically the requirement. i just want it in the given format

Hey @pritha.purkait

I have solved your query,

Workflow screenshot for reference:

Screenshot for your reference:
image

Attaching .xaml for your reference:
AddRows_Sequence.xaml (11.7 KB)

Regards,
Ajay Mishra

@pritha.purkait,

If this is static data means, the rows will be fixed as you shown in input you can use @Ajay_Mishras solution else the data is dynamic then you should be asking for logic from business in which your rows should be sorted.

Thanks,
Ashok :slight_smile:

@Ajay_Mishra This is close but if you look closely the last three are EURO then SGD then AUD.

@pritha.purkait Use this .xaml
AddRows_Sequence.xaml (14.8 KB)

Regards,
Ajay Mishra

1 Like

We can understand the use case as a custom sorting
When we define only a subset of custom sort definitions we would decide if other rows are place before or afterwards

Custom sort on USD, GBP, EURO, SGD, AUD others at the end

Assign Activity
arrCS = {"USD","GBP","EURO","SGD","AUD"}

Assign Activity
dtSorted =

(From d In dtData.AsEnumerable
Let cs = d("Currency").toString.ToUpper.Trim
Let ix = Array.IndexOf(arrCS.Reverse().ToArray, cs)
Order By ix Descending
Select r = d).CopyToDataTable
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.