Ordering of items in sales invoice

Ordering of items in sales invoice basing on from the highest to the smallest quantity using client side script