added node sorting based on weight