Update lib.php

Add order by weight in list functions.