creation of presorted data