fix iterator functions & add sort functionnality