Fix hashtable ordering assumptions
This is a port of gnome-keyring@4fa0719d to gcr, which has a (sort of) code copy of this stuff from gnome-keyring.
I've just cherry-picked the two patches that apply. The second one needed porting, since gcr has some different names for stuff - so reviews appreciated.
cc @dueno you might want to be the one to look, since you reviewed the original branch (thanks!)