added comments, made a function to sort tasks in order to share them based on their complexity, tidied up the code