cvs: /php3/functions basic_functions.c

From: Date: Tue, 21 Sep 1999 14:34:52 +0000
Subject: cvs: /php3/functions basic_functions.c
Groups: php.dev 
Request: Send a blank email to php-dev+get-11146@lists.php.net to get a copy of this message
thies Tue Sep 21 10:34:52 1999 EDT Modified files: /php3/functions basic_functions.c Log: just change the order Index: php3/functions/basic_functions.c diff -u php3/functions/basic_functions.c:1.275 php3/functions/basic_functions.c:1.276 --- php3/functions/basic_functions.c:1.275 Sun Aug 29 05:10:29 1999 +++ php3/functions/basic_functions.c Tue Sep 21 10:34:48 1999 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.275 1999/08/29 09:10:29 eschmid Exp $ */ +/* $Id: basic_functions.c,v 1.276 1999/09/21 14:34:48 thies Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -115,6 +115,7 @@ {"sleep", php3_sleep, NULL}, {"usleep", php3_usleep, NULL}, {"ksort", php3_key_sort, first_arg_force_ref}, + {"krsort", php3_key_rsort, first_arg_force_ref}, {"asort", php3_asort, first_arg_force_ref}, {"arsort", php3_arsort, first_arg_force_ref}, {"sort", php3_sort, first_arg_force_ref}, @@ -720,6 +721,34 @@ } } +static int array_reverse_key_compare(const void *a, const void *b) +{ return array_key_compare(a,b)*-1; +} + +/* {{{ proto int krsort(array array_arg) + Sort an array reverse by key */ +void php3_key_rsort(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *array; + TLS_VARS; + + if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &array) == FAILURE) { + WRONG_PARAM_COUNT; + } + if (!(array->type & IS_HASH)) { + php3_error(E_WARNING, "Wrong datatype in krsort() call"); + return; + } + if (!ParameterPassedByReference(ht,1)) { + php3_error(E_WARNING, "Array not passed by reference in call to krsort()"); + return; + } + if (_php3_hash_sort(array->value.ht, array_reverse_key_compare,0) == FAILURE) { + return; + } + RETURN_TRUE; +} +/* }}} */ /* {{{ proto int ksort(array array_arg) Sort an array by key */ void php3_key_sort(INTERNAL_FUNCTION_PARAMETERS)

« previous php.dev (#11146) next »