code: public List<Lock> lockAll(Object key1, Object key2) {
          Lock lock1 = this.locks.get(key1);
          Lock lock2 = this.locks.get(key2);
  
          int diff = lock1.hashCode() - lock2.hashCode();
          if (diff == 0 && lock1 != lock2) {
              diff = this.indexOf(lock1) - this.indexOf(lock2);
              assert diff != 0;
          }
  
          List<Lock> locks = diff > 0 ?
                             ImmutableList.of(lock2, lock1) :
                             ImmutableList.of(lock1, lock2);
  
          for (int i = 0; i < locks.size(); i++) {
              locks.get(i).lock();
          }
  
          return locks;
      }
docs: Lock two objects with sorted order
  NOTE: This is to optimize the performance of lockAll(keys)
  @param key1  The first object
  @param key2  The second object
  @return      locks for the two objects