Here is the code:
EDIT **** Please no more "this is not possible with disordered vocabulary answers." I have known this for a long time. I made this post in case it MAY be possible, or someone has a workable idea.
#position equals some set of two dimensional coords for name in self.regions["regions"]:
Hope the comments in the code explain my situation quite well. Suppose I was the last in the "delta" area (i.e., the key name is delta, the value will be the set of coordinates defining its boundaries), and I have another 500 regions. The first time I am in the region delta, the code may not have discovered this until it was supposedly (hypothetically) the 389th iteration ... so it did the 388 all(self.point_inside(rect, position)) calculations all(self.point_inside(rect, position)) before I discovered this. Since I will probably still be in deltas the next time I run (but I have to check that every time the code is executed), it would be useful if the "delta" key was the first one that was checked by the for loop.
This particular code can run many times per second for many different users .. therefore speed is critical. The design is such that very often the user will not be in the region, and all 500 entries may need to be scrolled and exit the loop without coincidence, but I would like to speed up the overall program, speeding it up for those that are currently in one from the regions.
I don't need the extra overhead of sorting the dictionary in any particular order, etc. I just want him to start looking for the last one that he successfully matched all(self.point_inside(rect, position))
Maybe this will help a little more. Below is the dictionary I'm using (only the first record shown) so you can see the structure I encoded above ... and yes, despite the name "rect" in the code, it actually checks for a point in the cubic area.
{"regions": {"shop": {"flgs": {"breakprot": true, "placeprot": true}, "dim": 0, "placeplayers": {"4f953255-6775-4dc6- a612-fb4230588eff ":" SurestTexas00 "}," breakplayers ": {" 4f953255-6775-4dc6-a612-fb4230588eff ":" SurestTexas00 "}," protected ": true," banplayers ": {}," pos1 ": [5120025, 60 , 5120208], "pos2": [5120062, 73, 5120257], "ownerUuid": "4f953255-6775-4dc6-a612-fb4230588eff", "accessplayers": {"4f953255-6775-4dc6-a612-fb4230588eff": " SurestTexas00 "}}, more, more, more ...}