working upvotes and sorting algo