4

i have a list of strings:

\\\\Tecan1\\tecan #1 output\\15939-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15942-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15945-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15948-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15951-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15954-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15957-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15960-E.ESY\r\n
\\\\Tecan1\\tecan #1 output\\15963-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15940-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15943-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15946-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15949-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15952-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15955-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15958-E.ESY\r\n
\\\\Tecan_2\\output on tecan 2\\15961-E.ESY\r\n
\\\\Tecan-5\\Output\\15941-E.ESY\r\n
\\\\Tecan-5\\Output\\15944-E.ESY\r\n
\\\\Tecan-5\\Output\\15947-E.ESY\r\n
\\\\Tecan-5\\Output\\15950-E.ESY\r\n
\\\\Tecan-5\\Output\\15953-E.ESY\r\n
\\\\Tecan-5\\Output\\15956-E.ESY\r\n
\\\\Tecan-5\\Output\\15959-E.ESY\r\n
\\\\Tecan-5\\Output\\15962-E.ESY\r\n

each \r\n should be a new line. sorry for the bad formatting

i need to sort the list of by the file name 15939-E.ESY, etc... i need the entire list in alphanumerical order by the filename. how would i sort it this way?

1
  • Do you have any code? That might show what kind of list it is for instance? Commented Dec 20, 2010 at 20:47

1 Answer 1

6

I'd use Path.GetFileName like this

list = list.OrderBy(s=>Path.GetFileName(s)).ToList();

Where list is a collection of those lines.

Sign up to request clarification or add additional context in comments.

3 Comments

just tried this and did not do anything . should i be sitting list = list.orderby........?
@herrow yeah you have to capture the IEnumberable that is returned. If you want to set it to the list you'll need a ToList on the end. See my updated answer.
@herrow Yes. The method returns an IOrderedEnumerable<T>, it does not sort the list in-place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.