Z
Z
Zefirot2021-07-24 11:56:59
C++ / C#
Zefirot, 2021-07-24 11:56:59

How to regroup by value dictionary?

I have a dictionary like this

private Dictionary<GameObject, float> Obj = new Dictionary<GameObject, float>();

then it is filled in and it turns out like such values ​​\u200b\u200bthere
Test1 => 20.19379
Test2 => 5.57432
Test3 => 1.34311
Test4 => 10.84457
...............

how to rebuild the dictionary so that the values ​​​​are only in ascending order?
Test3 => 1.34311
Test2 => 5.57432
Test4 => 10.84457
Test1 => 20.19379
...............

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-07-24
@Zefirot

var ordered = Obj.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question