Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

collator_sort(3) [php man page]

COLLATOR_SORT(3)							 1							  COLLATOR_SORT(3)

Collator::sort - Sort array using specified collator

	Object oriented style

SYNOPSIS
public bool Collator::sort (array &$arr, [int $sort_flag]) DESCRIPTION
Procedural style bool collator_sort (Collator $coll, array &$arr, [int $sort_flag]) This function sorts an array according to current locale rules. Equivalent to standard PHP sort(3) . PARAMETERS
o $coll -Collator object. o $arr - Array of strings to sort. o $sort_flag - Optional sorting type, one of the following: o Collator::SORT_REGULAR - compare items normally (don't change types) o Collator::SORT_NUMERIC - compare items numerically o Collator::SORT_STRING - compare items as strings Default sorting type is Collator::SORT_REGULAR. It is also used if an invalid $sort_flag value has been specified. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 collator_sort(3) example <?php $coll = collator_create( 'en_US' ); $arr = array( 'at', 'as', 'as' ); var_export( $arr ); collator_sort( $coll, $arr ); var_export( $arr ); ?> The above example will output: array ( 0 => 'at', 1 => 'as', 2 => 'as', )array ( 0 => 'as', 1 => 'as', 2 => 'at', ) SEE ALSO
Collator constants, collator_asort(3), collator_sort_with_sort_keys(3). PHP Documentation Group COLLATOR_SORT(3)

Check Out this Related Man Page

COLLATOR_ASORT(3)							 1							 COLLATOR_ASORT(3)

Collator::asort - Sort array maintaining index association

       Object oriented style

SYNOPSIS
public bool Collator::asort (array &$arr, [int $sort_flag]) DESCRIPTION
Procedural style bool collator_asort (Collator $coll, array &$arr, [int $sort_flag]) This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Array elements will have sort order according to current locale rules. Equivalent to standard PHP asort(3). PARAMETERS
o $coll -Collator object. o $arr -Array of strings to sort. o $sort_flag - Optional sorting type, one of the following: o Collator::SORT_REGULAR - compare items normally (don't change types) o Collator::SORT_NUMERIC - compare items numerically o Collator::SORT_STRING - compare items as strings Default $sort_flag value is Collator::SORT_REGULAR. It is also used if an invalid $sort_flag value has been specified. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 collator_asort(3)example <?php $coll = collator_create( 'en_US' ); $arr = array( 'a' => '100', 'b' => '50', 'c' => '7' ); collator_asort( $coll, $arr, Collator::SORT_NUMERIC ); var_export( $arr ); collator_asort( $coll, $arr, Collator::SORT_STRING ); var_export( $arr ); ?> The above example will output: array ( 'c' => '7', 'b' => '50', 'a' => '100', )array ( 'a' => '100', 'b' => '50', 'c' => '7', ) SEE ALSO
Collator constants, collator_sort(3), collator_sort_with_sort_keys(3). PHP Documentation Group COLLATOR_ASORT(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK help please

Hi, I have two files each with different record seperators, one with a pipe | and the other with a semi-colon ; How do you deal with this in awk? Any help appreciated specifically i need to change the RS to ; when the following statement operates on the second file (assets.dat) awk... (7 Replies)
Discussion started by: penfold
7 Replies

2. UNIX for Dummies Questions & Answers

to assign cut values to an array

i need to seperate values seperated by delimiters and assign it to an array.. can u plz help me on that. Variables = "asd,rgbh,(,rty,got,),sroe,9034," i need to assign the variables into arrays.. like.. var=asd var=rgbh.. and so on how do i do this. i need to reuse the values stored in... (6 Replies)
Discussion started by: Syms
6 Replies

3. Shell Programming and Scripting

Why do we use sort before compare ?

Dear All. Im trying to know how exactly the command "compare" works, does it compare line by line or field by field, and the most important thing is that why the files have to be sorted before we compare them? Thanks in advance (7 Replies)
Discussion started by: yahyaaa
7 Replies

4. UNIX for Dummies Questions & Answers

sorting ASCII string containing numbers

I have the following output where I need to sort the second column numerically (starting with IBMULT3580-TD10 and ending in IBMULT3580-TD123) Drv DriveName 0 IBMULT3580-TD13 1 IBMULT3580-TD18 2 IBMULT3580-TD14 3 IBMULT3580-TD10 4 IBMULT3580-TD11 5 IBMULT3580-TD17 ... (8 Replies)
Discussion started by: GKnight
8 Replies

5. Shell Programming and Scripting

awk script to split field data

Hi Experts, I have a Input.txt document which contains data fields seperated by tabs. There are 4 fields totally Named UNIQUE, ORDER, CONTACT and WINS. The UNIQUE field contains unique ID and the CONTACT field contains data seperated by comma in some records. I am looking to write an awk script... (12 Replies)
Discussion started by: forumthreads
12 Replies

6. Shell Programming and Scripting

help - exec time too long

Dear everyone... thanks to this forum I am able to do everyday more and more complex scripts...but now I come up with problem with optimisation.. problem 1 - optimise: here is my code: while read number do nawk -F "|" -v... (8 Replies)
Discussion started by: abdulaziz
8 Replies

7. Shell Programming and Scripting

sort -M

I would like to sort my reminders file, but it seems like "sort -M" does not compare months by time, but instead just sort them alphabetically so that the result is: Jul Jun Jun Jun Mar Mar instead of: Mar Mar Jun Jun Jun Jul Has anyone experienced this and can give some tip... (9 Replies)
Discussion started by: jostber
9 Replies

8. Shell Programming and Scripting

PERL : Sort substring occurrences in array of strings

Hi, My developer is on vacation and I am not sure if there is something which is easier for this. I have an array of strings. Each string in the array has "%" characters in it. I have to get the string(s) which have the least number of "%" in them. I know how I can get occurrences : ... (7 Replies)
Discussion started by: sinpeak
7 Replies

9. Shell Programming and Scripting

Using unix array in sql

Hi all, I have declared an array in unix as below. #!/bin/ksh arr=() for i in {0..4} do arr=$i; done. i want to insert these array variables into the oracle table.can you guys please help me in doing this. my code is as below. value=`sqlplus -s fos/fos << EOF begin for j in... (10 Replies)
Discussion started by: Mukta
10 Replies

10. Shell Programming and Scripting

Data Normalization

Hi, there Need help on rearranging the data. I have data in the following format. LAC = 040 DN = 24001001 EQN = 920- 2- 0- 1 CAT = MS OPTRCL (7 Replies)
Discussion started by: meetsriharsha
7 Replies

11. Shell Programming and Scripting

How to sort and compare files in more efficient manner?

Hello All, Iam using below method to sort and compare files. First iam doing sorting and changing the same file and then doing comparing and taking the final result to another file. sort -o temp.txt file1 mv temp.txt file1 sort -o temp.txt file2 mv temp.txt file2 sort -o temp.txt... (6 Replies)
Discussion started by: Vikram_Tanwar12
6 Replies

12. Programming

Integer array length

Hello; When I wrote a function to print out an array, void p_array(int arr) { int i; int size = sizeof(arr) / sizeof(int); // int size = sizeof (arr) / sizeof (arr); for (i = 0; i < size; i++) printf("%d ", arr); printf("\n"); }I could only print out the... (19 Replies)
Discussion started by: yifangt
19 Replies

13. UNIX for Dummies Questions & Answers

Arrays

Am using bash For eg: Suppose i have a array arr=(1 2 3 4 5 6 7 8 9 10 11 12) suppose i give input 5 to a script and script should able to print values greater than or equal to 5 like below: Input: 5 output: 5,6,7,8,9,10,11,12 (7 Replies)
Discussion started by: manid
7 Replies

14. Shell Programming and Scripting

Multidimensional array:awk error

awk -F'\t' -v OFS='\t' ' { if($2 in arr) { #print "Sahi", NR,arr for(k=2;k<=NF;k++){ # sum]+=$2 } } else { arr=NR #print "awk",NR for (k=3;k<=NF ; k++){ sum=$k } } } (7 Replies)
Discussion started by: genome
7 Replies

15. UNIX for Beginners Questions & Answers

Array length: ls and sort

Hi there, I'm listing files and sorting them. When I try to get length of array variable in which these files are stored I get 1 as value. That's weird. files_info="$(find $input_dir -name "*_CHR$i.info" | sort )" printf ${#files_info}"\n" #print length #--loop through... (6 Replies)
Discussion started by: genome
6 Replies