How to swap repeating DataRow

RowSwap.xlsx (11.1 KB)


Please check attached excel.

Problem - As you check excel there is repeating name “Mélodie” thrice. I want to get all three repeating records and put in at start of row and existing datarow will come after in series.

I have also added problem statement and solution needed for your reference in excel.

Please help me out to solve this problem statement.

Thank you.

Updating the answer

Update: Try below linq
dtInput.AsEnumerable.GroupBy(Function(col) col("Name").ToString).OrderByDescending(Function(rw) rw.Count).SelectMany(Function(g) g.Where(Function(r) true)).CopyToDataTable()

@ppr might have better linq then mine

1 Like

Hey @Muralikrishna_Surve

What’s the Business rule to find the highlighted record please ?


Here repeating names should come at top and other row should come after that.

Hope you got the solution.

1 Like

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