Added count inversions algorithm