fix bug. use cmp in recursive calls.
add inversion_count