I want to have a custom sort on a dictionary that I generate in a nested loop. I know that five records will always be there, but there could be others based on the data I go through. I essentially want those five records in a specific order, and then the order does not matter for all records after those five.
For example, I want this:
{"Entries": [], "Groups": [], "Admin": [], "Network": [], "XYZ": [], "Subnets": []}
to be sorted to this:
{"Admin": [], "Groups": [], "Network": [], "Subnets": [], "Entries": [], "XYZ": []}
Therefore, Admin, Groups, Network, Subnets, and Entries are the five that I want in that specific order at the beginning of the dictionary, and after that the remaining entries’ order does not matter. How can I do this?
I’ve re-thought out how I approach the entire situation, and found a method that works for me.
With a dataset like the following:
I just do the following, which works fine for me:
So basically, do what I need to do with the five items and delete them from the dataset. I’m comfortable with doing this, since I’m not using said dataset after this block of code. I don’t delete the remaining ones after I do work on them, because that’s unnecessary. Garbage collection will just blow away the whole dataset after the function’s been completed, right?