@SuppressWarnings("unchecked")
    private List<Object> arraySort(List<Object> array, Boolean ascendingOrder, Boolean nullFirst) {
        if (array == null || ascendingOrder == null || nullFirst == null) {
            return null;
        }

        // Separate the null and non-null elements
        List<Object> nonNullElements = new ArrayList<>();
        List<Object> nullElements = new ArrayList<>();

        for (Object element : array) {
            if (element == null || element.equals("")) {
                nullElements.add(element);
            } else {
                if (element instanceof Comparable) {
                    nonNullElements.add(element);
                } else {
                    throw new IllegalArgumentException("Array contains non-comparable elements.");
                }
            }
        }

        // Sort the non-null elements based on the ascendingOrder flag
        if (ascendingOrder) {
            Collections.sort(nonNullElements, new Comparator<Object>() {

                @SuppressWarnings("unchecked")
                @Override
                public int compare(Object o1, Object o2) {
                    return ((Comparable<Object>) o1).compareTo(o2);
                }
            });
        } else {
            Collections.sort(nonNullElements, new Comparator<Object>() {

                @SuppressWarnings("unchecked")
                @Override
                public int compare(Object o1, Object o2) {
                    return ((Comparable<Object>) o2).compareTo(o1);
                }
            });
        }

        // Combine null and non-null elements based on nullFirst flag
        List<Object> sortedArray = new ArrayList<>();
        if (nullFirst) {
            // NULLs go first
            sortedArray.addAll(nullElements);
            sortedArray.addAll(nonNullElements);
        } else {
            // NULLs go last
            sortedArray.addAll(nonNullElements);
            sortedArray.addAll(nullElements);
        }

        return sortedArray;
    }
ArraySortFunction  ->  ARRAY_SORT(array[, ascending_order[, null_first]])
description:
- Return NULL if 'array' is null;
- Return the array in sorted order.
Note: The function sorts an array, defaulting to ascending order with NULLs at the start when only the array is input.
      Specifying ascending_order as true orders the array in ascending with NULLs first, and setting it to false orders
      it in descending with NULLs last. Independently, null_first as true moves NULLs to the beginning, and as false
      to the end, irrespective of the sorting order. The function returns null if any input is null.
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/collection/ArraySortFunction.java