ok so I'm having major issues trying to figure this out:
I have this program that I'm inputting the files in hte current directory which are image files...it spits out 5 line chunks describing the files...
filename: (name of file)
size: (100 x 200)
arbitrary data
arbitrary data
arbitrary... (4 Replies)
How to sort such files which contains records of varying length and varying lines? (With respect to Bash shell)
Eg:
Each record begins with a sting of 1/0(binary) which may or may not be followed by properties like AB,BS etc.
I have to sort such records on the basis of 1/0 string and keep the... (2 Replies)
hi
i have file like below:
col1,col2,col3,col4
val1,val2,val3,val4
abc1,abc2,abc3,abc4
this is a 4 column file with 3 rows.
i want to sort the file like.. first on col1, then on col2 and so ..on..
i want the sort order to be descending.
Pls help..
Thnks
Sumit (2 Replies)
Hi,
i have file1 which looks like:
x1 y1 z1
x2 y2 z2
...(and so on)
and file2 which looks like:
a11 a12 a13
a21 a22 a23
a31 a32 a33
and i want to replace file1 with the following values:
x1' y1' z1'
x2' y2' z2'
...(and so on) (2 Replies)
i have file a
123
234
456
567
678
and file b
123|xxx|hhh|ppp or zzz
234|rrr|ttt|xxx
432|ttt|mmm|nnn
678|cft|byt|mop
i want to compare file a to file b such that when each of the lines in file a can be found in file b column1 and also xxx or hhh or ppp or zzz can be... (12 Replies)
I have the following set of files and I want to order them according to the ascending values of the run:
For example, doing
ls -lrt *drw*.log
gives
n02-z30-sr65-rgdt0p25-dc0p08-4x3drw.log
n02-z30-sr65-rgdt0p25-dc0p03-8x6drw.log
n02-z30-sr65-rgdt0p25-dc0p01-8x6drw.log
... (18 Replies)
Hi,
This is something that probably it is more difficult to explain than to do.
I have two files e.g.
FILE1
A15 8.3102E+00 3.2000E-04
A15 8.5688E+00 4.3000E-05
B13 5.1100E-01 1.9960E+00
B16 5.1100E-01 2.3000E-03
B16 8.6770E-01 1.0000E-07
B16 9.8693E-01 3.4000E-05... (4 Replies)
Hi,
I have two files (file1.txt, file2.txt) in which, I would like to multiply all the values in file1 with the first row value of file2, file1 * second row value of file2, file1 * third row value of file2 and so on.
Below are my sample data.
file1.txt file2.txt ... (6 Replies)
Discussion started by: ida1215
6 Replies
LEARN ABOUT PHP
natsort
NATSORT(3) 1 NATSORT(3)natsort - Sort an array using a "natural order" algorithm
SYNOPSIS
bool natsort (array &$array)
DESCRIPTION
This function implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key/value
associations. This is described as a "natural ordering". An example of the difference between this algorithm and the regular computer
string sorting algorithms (used in sort(3)) can be seen in the example below.
PARAMETERS
o $array
- The input array.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
|5.2.10 | |
| | |
| | Zero padded numeric strings (e.g., '00005') now |
| | essentially ignore the 0 padding. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
natsort(3) examples demonstrating basic usage
<?php
$array1 = $array2 = array("img12.png", "img10.png", "img2.png", "img1.png");
asort($array1);
echo "Standard sorting
";
print_r($array1);
natsort($array2);
echo "
Natural order sorting
";
print_r($array2);
?>
The above example will output:
Standard sorting
Array
(
[3] => img1.png
[1] => img10.png
[0] => img12.png
[2] => img2.png
)
Natural order sorting
Array
(
[3] => img1.png
[2] => img2.png
[1] => img10.png
[0] => img12.png
)
For more information see: Martin Pool's Natural Order String Comparison page.
Example #2
natsort(3) examples demonstrating potential gotchas
<?php
echo "Negative numbers
";
$negative = array('-5','3','-2','0','-1000','9','1');
print_r($negative);
natsort($negative);
print_r($negative);
echo "Zero padding
";
$zeros = array('09', '8', '10', '009', '011', '0');
print_r($zeros);
natsort($zeros);
print_r($zeros);
?>
The above example will output:
Negative numbers
Array
(
[0] => -5
[1] => 3
[2] => -2
[3] => 0
[4] => -1000
[5] => 9
[6] => 1
)
Array
(
[2] => -2
[0] => -5
[4] => -1000
[3] => 0
[6] => 1
[1] => 3
[5] => 9
)
Zero padding
Array
(
[0] => 09
[1] => 8
[2] => 10
[3] => 009
[4] => 011
[5] => 0
)
Array
(
[5] => 0
[1] => 8
[3] => 009
[0] => 09
[2] => 10
[4] => 011
)
SEE ALSO natcasesort(3), The comparison of array sorting functions, strnatcmp(3), strnatcasecmp(3).
PHP Documentation Group NATSORT(3)