Merge sortcode and inversion count