src/function/relational/compareNatural.js
function compareObjects (x, y) {
    const keysX = Object.keys(x)
    const keysY = Object.keys(y)

    // compare keys
    keysX.sort(naturalSort)
    keysY.sort(naturalSort)
    const c = compareArrays(keysX, keysY)
    if (c !== 0) {
      return c
    }

    // compare values
    for (let i = 0; i < keysX.length; i++) {
      const v = compareNatural(x[keysX[i]], y[keysY[i]])
      if (v !== 0) {
        return v
      }
    }

    return 0
  }
function compareObjects (x, y) {
    const keysX = Object.keys(x)
    const keysY = Object.keys(y)

    // compare keys
    keysX.sort(naturalSort)
    keysY.sort(naturalSort)
    const c = compareArrays(keysX, keysY)
    if (c !== 0) {
      return c
    }

    // compare values
    for (let i = 0; i < keysX.length; i++) {
      const v = compareNatural(x[keysX[i]], y[keysY[i]])
      if (v !== 0) {
        return v
      }
    }

    return 0
  }
function compareObjects ( x , y ) { const keysX = Object . keys ( x ) const keysY = Object . keys ( y ) // compare keys keysX . sort ( naturalSort ) keysY . sort ( naturalSort ) const c = compareArrays ( keysX , keysY ) if ( c !== 0 ) { return c } // compare values for ( let i = 0 ; i < keysX . length ; i ++ ) { const v = compareNatural ( x [ keysX [ i ] ] , y [ keysY [ i ] ] ) if ( v !== 0 ) { return v } } return 0 }
Compare two objects

- First, compare sorted property names
- Next, compare the property values

@param {Object} x
@param {Object} y
@returns {number} Returns the comparison result: -1, 0, or 1
Compare two objects