Prefer closest equal item in scalarize

fixes andreyvit/json-diff#1
Empty objects should match
Merge pull request #2 from nigelzor/better-equality

Improve comparision of arrays with repeated or empty elements