Filter the unique values into a new array
@param arr
342537
function uniqueArray(arr) {
  var result = [];

  for (var i = 0; i < arr.length; i++) {
    if (result.indexOf(arr[i]) === -1) {
      result.push(arr[i]);
    }
  }

  return result;
}
1033343
private function arrayFilterRecursive(array &$array)
    {
        foreach ($array as $key => &$item) {
            is_array($item) && $array[$key] = $this->arrayFilterRecursive($item);
            if ($array[$key] === null ||
                $array[$key] === []
            ) {
                unset($array[$key]);
            }
        }
        return $array;
    }
1341910
public static int[] Unique(int[] values) {
        HashSet<Integer> lst = new HashSet<Integer>();
        for (int i = 0; i < values.length; i++) {
            lst.add(values[i]);
        }

        int[] v = new int[lst.size()];
        Iterator<Integer> it = lst.iterator();
        for (int i = 0; i < v.length; i++) {
            v[i] = it.next();
        }

        return v;
    }
938526
function uniqueize(a) {
  return a.filter((elt, i) => a.indexOf(elt) === i);
}
789881
function allUnique(arr) {
    var hash = {},
        index,
        len;

    for (index = 0, len = arr.length; index < len; index++) {
        if (hash[arr[index]]) {
            return false;
        }
        hash[arr[index]] = true;
    }
    return true;
}
905268
def distinct_values driver = nil
      @distinct_values ||= values || @filters.values.inject({}){|memo, filter| memo[filter.name] = filter.label; memo }
    end
449877
function filter( arr, str ) {
	var len = arr.length,
		out = [],
		i;

	for ( i = 0; i < len; i++ ) {
		if ( arr[ i ] !== str ) {
			out.push( arr[ i ] );
		}
	}
	return out;
}
1177682
public static void sort(int[] arr) {
        int n = arr.length;
        for (int i = n / 2 - 1; i >= 0; i--)
            SortUtils.siftDown(arr, i, n - 1);

        for (int i = n - 1; i > 0; i--) {
            SortUtils.swap(arr, 0, i);
            SortUtils.siftDown(arr, 0, i - 1);
        }
    }
65570
function unique(array) {
  const results = [];

  for (let idx = 0, len = array.length; idx < len; idx++) {
    if (!contains(results, array[idx])) {
      results.push(array[idx]);
    }
  }

  return results;
}
1027181
function customUnique(array) {
  const unique = uniqBy(array, 'fname');
  // we construct unique portlets array will all linked categories (reversing category and portlets child)
  unique.forEach((elem) => {
    const dupl = array.filter((e) => e.fname === elem.fname);
    const allCategories = dupl.flatMap(({categories}) => categories);
    elem.categories = [...new Set(allCategories)];
  });
  return unique;
}
843094
static function sanitize_array(&$arr)
	{
		foreach ( $arr as $k => $v )
			$arr[$k] = self::sanitize($v);
			
		return $arr;
	}
303476
function unique( arr, sorted ) {
	if ( !Array.isArray( arr ) ) {
		throw new TypeError( 'unique()::invalid input argument. First argument must be an array.' );
	}
	if ( arguments.length > 1 && typeof sorted !== 'boolean' ) {
		throw new TypeError( 'unique()::invalid input argument. Second argument must be an array.' );
	}
	var len = arr.length,
		i, j,
		val;

	if ( !len ) {
		return;
	}
	if ( !sorted ) {
		arr.sort( ascending );
	}
	// Loop through the array, only incrementing a pointer when successive values are different. When a succeeding value is different, move the pointer and set the next value. In the trivial case where all array elements are unique, we incur a slight penalty in resetting the element value for each unique value. In other cases, we simply move a unique value to a new position in the array. The end result is a sorted array with unique values.
	for ( i = 1, j = 0; i < len; i++ ) {
		val = arr[ i ];
		if ( arr[ j ] !== val ) {
			j++;
			arr[ j ] = val;
		}
	}
	// Truncate the array:
	arr.length = j+1;
}
120832
def unique(values):
    '''
    
    '''
    ret = None
    if isinstance(values, collections.Hashable):
        ret = set(values)
    else:
        ret = []
        for value in values:
            if value not in ret:
                ret.append(value)
    return ret
204867
private void arrayFillDefaultValue(Object arr) {
        if (null == arr)
            return;
        Class<?> clas = arr.getClass();
        Class<?> comp = Types.arrayElementType(clas);
        if ( !comp.isPrimitive() )
            if ( Types.arrayDimensions(clas) > 1 )
                for ( int i = 0; i < Array.getLength(arr); i++ )
                    arrayFillDefaultValue(Array.get(arr, i));
            else
                Arrays.fill((Object[]) arr, Primitive.unwrap(
                    Primitive.getDefaultValue(comp)));
    }
871740
public function filterCategoryValues($values)
    {
        return array_unique(preg_split(
            '/\s*,\s*/u',
            preg_replace('/\s+/u', ' ', is_array($values) ? implode(',', $values) : $values),
            -1,
            PREG_SPLIT_NO_EMPTY
        ));
    }
1043988
function filter(arr, cb, thisArg) {
  cb = makeIterator(cb, thisArg);
  if (arr == null) {
    return [];
  }
  var len = arr.length;
  var res = [];
  for (var i = 0; i < len; i++) {
    var ele = arr[i];

    if (cb(ele, i, arr)) {
      res.push(ele);
    }
  }
  return res;
}
494428
public static function getSortedArrayByValue($arr)
    {
        $duplicate = self::copyArray($arr);

        if ($duplicate === null) {
            return null;
        }

        asort($duplicate);

        return $duplicate;
    }