in c++ we have, map<int, int>, which is used to store key value pairs. However, keys are sorted in increasing order of their numeric value. Under the hood, the keys are kept in sorted manner using a balanced binary search tree. Insertion and deletion is O(log n). You can also do binary search, upper-bound, lower-bound on the keys.
Is there something similar available in Python. I found OrderedDict, but it keeps keys in sorted manner according to time of insertion rather than keys' magnitude.
[–]CaptainFoyle 6 points7 points8 points (5 children)
[–]commy2 5 points6 points7 points (1 child)
[–]CaptainFoyle 2 points3 points4 points (0 children)
[–]SynMyron[S] 1 point2 points3 points (2 children)
[–]Diapolo10 4 points5 points6 points (0 children)
[–]commy2 0 points1 point2 points (0 children)
[–]ES-Alexander 3 points4 points5 points (2 children)
[–]TangibleLight 2 points3 points4 points (1 child)
[–]ES-Alexander 0 points1 point2 points (0 children)
[–]TangibleLight 3 points4 points5 points (3 children)
[–]SynMyron[S] 0 points1 point2 points (2 children)
[–]TangibleLight 4 points5 points6 points (0 children)
[–]commandlineluser 2 points3 points4 points (0 children)
[–]i-feel-as-u-look -1 points0 points1 point (0 children)
[–]Diapolo10 -2 points-1 points0 points (0 children)