private ArrayList<PositionList.Entry> buildSortedPositions() {
    int sz = (positions == null) ? 0 : positions.size();
    ArrayList<PositionList.Entry> result = new ArrayList(sz);

    for (int i = 0; i < sz; i++) {
      result.add(positions.get(i));
    }

    // Sort ascending by address.
    Collections.sort(
        result,
        new Comparator<PositionList.Entry>() {
          @Override
          public int compare(PositionList.Entry a, PositionList.Entry b) {
            return a.getAddress() - b.getAddress();
          }

          @Override
          public boolean equals(Object obj) {
            return obj == this;
          }
        });
    return result;
  }
Builds a list of position entries, sorted by ascending address.

@return A sorted positions list
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/file/DebugInfoEncoder.java