public List<Size> getBestPreviewOrder(List<Size> sizes, final Size desired) {
        if (desired == null) {
            return sizes;
        }

        Collections.sort(sizes, new Comparator<Size>() {
            @Override
            public int compare(Size a, Size b) {
                float aScore = getScore(a, desired);
                float bScore = getScore(b, desired);
                // Bigger score first
                return Float.compare(bScore, aScore);
            }
        });


        return sizes;
    }
Sort previews based on their suitability.

In most cases, {@link #getBestPreviewSize(List, Size)} should be used instead.

The sizes list may be reordered by this call.

@param sizes supported preview sizes, containing at least one size. Sizes are in natural camera orientation.
@param desired The desired viewfinder size, in the same orientation
@return an ordered list, best preview first
zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/PreviewScalingStrategy.java