class KeyValue
    {
        private final String key;
        private final String value;
        
        KeyValue(final String theKey, final String theValue)
        {
            this.key = theKey;
            this.value = theValue;
        }
        
        public String getKey()
        {
            return this.key;
        }

        public String getValue()
        {
            return this.value;
        }
        
        @Override
        public String toString()
        {
            return "(" + this.key + ", " + this.value + ")";
        }
    }

    /**
     * Constructor.
     */
    private FieldUtils()
    {
    }
    
    /**
     * Return two related lists as a single list with key value pairs.
     * 
     * @param key the key elements
     * @param value the value elements
     * @return a sorted list of KeyValue elements.
     */
    static List<KeyValue> toKeyValueList(List<String> key, List<String> value)
    {
        List<KeyValue> list = new ArrayList<>(key.size());
        for(int i =0; i<key.size(); i++)
        {
            list.add(new FieldUtils.KeyValue(key.get(i),value.get(i)));
        }
        return list;
    }    
    
    /**
     * Sort two related lists simultaneously by the elements in the key parameter.
     * 
     * @param pairs a list of KeyValue elements
     */
    static void sortByValue(List<KeyValue> pairs)
    {
        pairs.sort(BY_VALUE_COMPARATOR);
    }

    /**
     * Sort two related lists simultaneously by the elements in the value parameter.
     * 
     * @param pairs a list of KeyValue elements
     */
    static void sortByKey(List<KeyValue> pairs)
    {
        pairs.sort(BY_KEY_COMPARATOR);
    }
    
    /**
     * Return either one of a list which can have two-element arrays entries.
     * <p>
     * Some entries in a dictionary can either be an array of elements
     * or an array of two-element arrays. This method will either return
     * the elements in the array or in case of two-element arrays, the element
     * designated by the pair index
     * </p>
     * <p>
     * An {@link IllegalArgumentException} will be thrown if the items contain
     * two-element arrays and the index is not 0 or 1.
     * </p>
     * 
     * @param items the array of elements or two-element arrays
     * @param pairIdx the index into the two-element array
     * @return a List of single elements
     */
    static List<String> getPairableItems(COSBase items, int pairIdx)
    {<FILL_FUNCTION_BODY>

        if (pairIdx < 0 || pairIdx > 1) 
        {
            throw new IllegalArgumentException("Only 0 and 1 are allowed as an index into two-element arrays");
        }
        
        if (items instanceof COSString)
        {
            List<String> array = new ArrayList<>(1);
            array.add(((COSString) items).getString());
            return array;
        }
        else if (items instanceof COSArray)
        {
            List<String> entryList = new ArrayList<>(); 
            for (COSBase entry : (COSArray) items)
            {
                if (entry instanceof COSString)
                {
                    entryList.add(((COSString) entry).getString());
                }
                else if (entry instanceof COSArray)
                {
                    COSArray cosArray = (COSArray) entry;
                    if (cosArray.size() >= pairIdx +1 && cosArray.get(pairIdx) instanceof COSString)
                    {
                        entryList.add(((COSString) cosArray.get(pairIdx)).getString());
                    }
                }
            }
            return entryList;
        }
        return Collections.emptyList();
    
<no_super_class>