Fix #12: JSON serialization-error in "Save ferm local facts".

Make unique first, then sort. (And this is quicker, too).