Complete index comparing function