Sort list of class objects in c# [duplicate]

This question already has an answer here:

I want to sort list of class objects.

class tocka
{
Point t;
double kut;
int redkotiranja;

public tocka(Point _t, double _kut, int _redkotiranja)
{
t = _t;
kut = _kut;
redkotiranja = _redkotiranja;
}
}

Here is the list:

List tocke= new List();
tocka a = new tocka(new Point(0, 1), 10, 1);
tocke.Add(a);
tocka b = new tocka(new Point(5, 1), 10, 1);
tocke.Add(b);
tocka c = new tocka(new Point(2, 1), 10, 1);
tocke.Add(c);
tocka d = new tocka(new Point(1, 1), 10, 1);
tocke.Add(d);
tocka ee = new tocka(new Point(9, 1), 10, 1);
tocke.Add(ee);

I want to sort list tocke by t.X

How I do that in C#?

How to Sort a List by a property in the object

I have a class called Order which has properties such as OrderId, OrderDate, Quantity, and Total. I have a list of this Order class:

List objListOrder = new List();
GetOrderList(objListOrder); // fill list of orders

Now I want to sort the list based on one property of the Order object, for example I need to sort it by the order date or order id.

How can i do this in C#?

How can I sort a list of objects by a member of each object? [duplicate]

This question already has an answer here:

class candle
{
    public DateTime date { get; set; }
    public double open { get; set; }
    public double high { get; set; }
    public double low { get; set; }
    public double close { get; set; }     
}
List candleList = new List();

Assuming I have added many candles to candeList, How can I then sort candleList by date?

Also, how can I remove all duplicate entries from candleList?

Thank you

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.

remove all strings from list containing certain substring

I’ve got a list of strings called albumList
the string has this structure: abc,abc,abc,abc,abc
I ask the user to search an album to delete; if the album is found, it will be deleted from the list. There could be more than one album with the same name to be deleted from the list.

 private void searchAlbumName(string search)
        {
            string[] cellVal;
            foreach (string x in albumList)
            {
                cellVal = x.Split(',');
                if (cellVal[0].ToString().Equals(search))
                {
                    //do delete here
                }
            }
        }

I’m not sure how to remove every album with the search name

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.

Remove Item have same key in List C# [duplicate]

This question already has an answer here:

I have a List n Objects.
In n Objects have some object that they have same Id.
Example List = {t1, t2, t3, t4, t5....,t10}.

assuming that:

t1.Id = t5.id

So i want to remove t5 from that List.

Who can help me plz.

In this question: using LINQ to remove objects within a List you know that object duplicates (ex: “bob”), but in my question, in this List, i don’t know any object duplicate before.

Using LINQ to remove elements from a List

Say that I have LINQ query such as:

var authors = from x in authorsList
              where x.firstname == "Bob"
              select x;

Given that authorsList is of type List, how can I delete the Author elements from authorsList that are returned by the query into authors?

Or, put another way, how can I delete all of the firstname’s equalling Bob from authorsList?

Note: This is a simplified example for the purposes of the question.