Thursday 26 October 2017

c# - Order List by property name

I have a
class


public class
Test
{
public string Value { get; set;
}
}

and
then


List values = new
List() //contains 10
items

Some Items in the list
their Value property can start with the character
>


Example:



Name
Something
Example
> Another one

Demo
Student
>
Home

How can I sort my list of
objects so that the first items in the list are sorted alphabetically and the ones that
start with > are sorted alphabetically as well but are at
the end of the list?


This is what I did so
far:


values.Where(x =>
!x.Value.StartsWith(">")).OrderBy(x =>
x.Value);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...