Pchp.Library.Arrays.usort C# (CSharp) Method

usort() public static method

Sorts an array using user comparison callback for comparing values.
Resets array's intrinsic enumerator.
public static usort ( Context ctx, [ array, IPhpCallable compare ) : bool
ctx Pchp.Core.Context Current runtime context.
array [ The array to be sorted.
compare IPhpCallable The user callback to be used for comparison of values.
return bool
        public static bool usort(Context ctx /*, caller*/, [In, Out] PhpArray array, IPhpCallable compare)
        {
            if (array == null)
            {
                //PhpException.ReferenceNull("array");
                //return false;
                throw new ArgumentNullException();
            }
            if (!PhpVariable.IsValidCallback(compare)) return false;

            // sorts array using callback for comparisons:
            array.Sort(new ValueComparer(new PhpUserComparer(ctx, compare), false));

            array.ReindexAll();
            array.RestartIntrinsicEnumerator();

            return true;
        }