Copy the resulting Map into an implementation of SortedMap, e.g. TreeMap.
Like this (sort by key):
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
TreeMap<String, ?> keys = new TreeMap<String, Object>(myPrefs.getAll());
for (Map.Entry<String, ?> entry : keys.entrySet()) {
    Log.i("map values", entry.getKey());
    //some code
}
To sort by value & not lose any key-value pairs (since a Map will readily allow duplicate values mapping to different keys) you'd need to first convert it into
a List and sort that.
    List<Pair<Object, String>> sortedByValue = new LinkedList<Pair<Object,String>>();
    for (Map.Entry<String, ?> entry : keys.entrySet()) {
        Pair<Object, String> e = new Pair<Object, String>(entry.getValue(), entry.getKey());
        sortedByValue.add(e);
    }
    // Pair doesn't have a comparator, so you're going to need to write one.
    Collections.sort(sortedByValue, new Comparator<Pair<Object, String>>() {
        public int compare(Pair<Object, String> lhs, Pair<Object, String> rhs) {
            // This is a naive and shitty comparator, but it works for
            // arbitrary objects. Sort of. Tweak depending on the order you need.
            String sls = String.valueOf(lhs.first);
            String srs = String.valueOf(rhs.first);
            int res = sls.compareTo(srs);
            // Sort on value first, key second
            return res == 0 ? lhs.second.compareTo(rhs.second) : res;
        }
    });
    for (Pair<Object, String> pair : sortedByValue) {
        Log.i("map values", pair.first + "/" + pair.second);
    }