function compareItem(item, device) {
        var prev = item.previousSibling
        var next = item.nextSibling
        var diff

        if (prev) {
          diff = compare(device, mapping[prev.id])
          if (diff < 0) {
            return diff
          }
        }

        if (next) {
          diff = compare(device, mapping[next.id])
          if (diff > 0) {
            return diff
          }
        }

        return 0
      }
// item, or 0 if the position is already correct.
item, or 0 if the position is already correct.
item or 0 if the position is already correct .
function compareItem(item, device) {
        var prev = item.previousSibling
        var next = item.nextSibling
        var diff
        if (prev) {
          diff = compare(device, mapping[prev.id])
          if (diff < 0) {
            return diff
          }
        }
        if (next) {
          diff = compare(device, mapping[next.id])
          if (diff > 0) {
            return diff
          }
        }
        return 0
      }
function compareItem ( item , device ) { var prev = item . previousSibling var next = item . nextSibling var diff if ( prev ) { diff = compare ( device , mapping [ prev . id ] ) if ( diff < 0 ) { return diff } } if ( next ) { diff = compare ( device , mapping [ next . id ] ) if ( diff > 0 ) { return diff } } return 0 }
item, or 0 if the position is already correct.
item or 0 if the position is already correct .