Implementing and fixing sorting web histories into categories and preparing input for the algorithm