How do you sort a dictionary by value?

There are a lot of resources on google, but none of them seem to work. It doesn’t let me use a SortedDictionary either.

I’m trying to get an index of a list of GameObjects, and assign their GetDistanceFromPlayer return value as the value of the dictionary. Then I want to sort it and use the values to make a new list of GameObjects with the distance sorted from lowest to highest. I’m obviously not asking you to write my code for me, but it would be great to get an actual functional function I can use to at least start in the right direction.

If you really need to use a dictionary (and not a SortedList as @Jamora suggests), try this: c# - How do you sort a dictionary by value? - Stack Overflow

This is a general way of sorting a list of CustomClass based on a custom variable in the class:

List<CustomClass> list = new List<CustomClass>();

//Fill with objects of CustomClass...

list.Sort((x,y) => x.CustomIntVariable.ComareTo(y.CustomIntVariable));