How do I sort a dictionary by value?

I have a dictionary of values read from two fields in a database: a string field and a numeric field. The string field is unique, so that is the key of the dictionary.

I can sort on the keys, but how can I sort based on the values?

Note: I have read Stack Overflow question How do I sort a list of dictionaries by values of the dictionary in Python? and probably could change my code to have a list of dictionaries, but since I do not really need a list of dictionaries I wanted to know if there is a simpler solution.

Sort ArrayList of custom Objects by property

I read about sorting ArrayLists using a Comparator but in all of the examples people used compareTo which according to some research is a method for Strings.

I wanted to sort an ArrayList of custom objects by one of their properties: a Date object
(getStartDay()). Normally I compare them by item1.getStartDate().before(item2.getStartDate()) so I was wondering whether I could write something like:

public class CustomComparator {
    public boolean compare(Object object1, Object object2) {
        return object1.getStartDate().before(object2.getStartDate());

public class RandomName {
    Collections.sort(Database.arrayList, new CustomComparator);

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);
tocka b = new tocka(new Point(5, 1), 10, 1);
tocka c = new tocka(new Point(2, 1), 10, 1);
tocka d = new tocka(new Point(1, 1), 10, 1);
tocka ee = new tocka(new Point(9, 1), 10, 1);

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