An algorithms assignment to count inversions and deal with them.