我们需要它用于以下用例:
var myPerceptualHash = '0239582305980';
db.coll1.find().sort({
$by : function( a, b ) {
var md = require('hamming-distance');
return hm(myPerceptualHash, a.phash) < hm(myPerceptualHash, b.phash);
}
}).limit(1)
这甚至比仅仅定义一个将 a 与 b 关联起来的排序函数更加特殊,因为它需要使用“外部”参数来对比排序的时刻。