Extract sorting to a mixin and add it to history

Extract the sort logic from the app overview page into a generic mixin.
Use the same mixin to enable sort on the history page.