ok. but when I am debugging , i saw... every time the loop runs, as the "i" value increments, the originalIndex value also increments.. always their value is same. that's y its not going to be true anytime. int originalIndex = dt.AsEnumerable().ToList().FindIndex(x => x["Department"] == dt.Rows[i]["Department"]); here originalIndex value is dependent on "i" everytime so it will find the index of that row according to i value right. so as an example, when i == 0 , then it will find the index of department corresponds to 0th row and so on.... then how it is coming different in your case, I am not getting really. :) if you don't mind can you please re-check if you have made any small code changes inside this please
in this case the condition if (originalIndex < i) always is false and thus not removing the duplicate names. i think we should go for a counter or flag concept
in this case the condition if (originalIndex < i) always is false and thus not removing the duplicate names.
Name Department John Alter D01 Prakash Kiran D01 Steffy Cold D01 Julia Roberts D02 Candy Mitchel D02 Monika Diesel D03
Name Department John Alter D01 Prakash Kiran Steffy Cold Julia Roberts D02 Candy Mitchel Monika Diesel D03
dt = dt.AsEnumerable().OrderBy(x => (x.ItemArray[0] as string).Split(' ')[(x.ItemArray[0]).ToString().Split(' ').Length - 1]).CopyToDataTable();
yeah only last part. like in case of the below name: Mary Sue Van Pelt "Pelt" would be the last name
can you explain the use of "Split(' ')[1]" in the query please ???