+# First load the list of installed packages as a list of lines
+f = open("installierte-pakete-2009-01-29.txt", "r")
+instl = f.read().splitlines()
+#: A list of numbers for overlays
+overlays = ["[" + str(i) + "]" for i in range(100)]
+#: The counts for each overlay.
+#: The corresponding names
+# Now just count the number of times, the overlay number appers in the data.
+ # if we don't yet have an entry for the overlay,
+ # we create one with 0!
+ # reason: every overlay appears again at the end.
+ if not number in counts:
+# Now we clean out empty entries from counts.
+# For this we just grab the first appearance of the number in the
+# reversed list of lines, but only for the actually existing overlays.
+# finally sort the overlays by the number of appearances and print it
+# put counts in a list we can sort by the number of appearances.
+ overlay_list.append((counts[number], number))
+# Print the highest count first
+for count, number in overlay_list:
+ print count, names[number]