public static boolean isOrdered(List<Partition> partitions) {
        List<Long> lengths = new ArrayList<Long>();
        for (Partition partition : partitions) {
            lengths.add(partition.getLength());
        }

        // Ignore trailing 0 length blocks.
        while (lengths.size() > 0 && lengths.get(lengths.size() -1) == 0) {
            lengths.remove(lengths.size() -1);
        }

        for (int index = 0; index < lengths.size() - 1; index++) {
            if (lengths.get(index) > lengths.get(index + 1)) {
                return false;
            }
        }
        return true;
    }