I have a dict which is part of a SpriteSheet
class of the attribute sprite_info
. sprite info
holds the names and location and xd/yd of each sprite on the sheet, i.e.
{'stone_Wall' : { 'x': '781', 'xd': '70', 'y': '568', 'yd': '70'} ... }
What I'd like to do is sort the dict by each name. In other words, there are other names in the list list stone_Right
and stone_Mid
and so on. The one thing they all have in common is stone_
.
What's the most efficient way of doing this? My limited experience tells me to just go into a bunch of nested for-loops, but I know there's a better way.
Further clarification:
Once everything is sorted, I would like to separate the dict by name. Using my example, for any key that includes stone
or stone_
, add it to a new dict within the already existing dict.