Is it about sorting of arguments that are given to a script or a script function?
The sorting of arguments requires an explicit sorting, either with an external sort command or with a sort function.
A newline is an obstacle for the external sort command, unless sort understands -t $'\0' or similar tricks.
A shell function can do it, as shown by the following sample:
Proper quoting of variables in command arguments is important! Only then all special characters are treated normal, even newline characters.
--
You haven't provided your shell script yet. So maybe my assumptions were totally wrong...
Hi, I'm a pretty big fan of BASH scripting. I've got a bunch I use for random things and lately a couple issues have been plaguing me.
Both are somewhat related, in that they deal with filenames with spaces and "escaped" characters and with launching a program with command line arguements... (5 Replies)
Hi I have 2 files a.c and a.bak where I changed long to int using awk script.
I want to get the list of functions whose parameters got modified
for eg: fun ( long a, long b ) might be changed to fun ( int a, int b ) (1 Reply)
Hello,
I've got next problem:
I want to examine at the beginning of a script in an if loop that:
1. Is there 4 parameters given
2. If first state is true then: is there switches -e and -d?
3. At the end, how can i indentify them as variebles regardlees to its order.
I was thinking like... (2 Replies)
Hi, I am trying to do this thing useing my shell bash ( sorry for my english )
I have in a file 63 hostnames, i wanna ask to the DHCP admin, to reserv that reserves 63 IP addresses of this hosts, using their mac address.
I have thinked this script:
for ((i=1;i<63;i++)); do
arp $(head... (10 Replies)
Hi,
So I have a web page that has some drop down boxes with a whole bunch of entries. Unfortunately, they have been added over time and started from a small list and is now extremely messy. I'm looking to write script so I can just copy in the section of the HTML code and have it sorted for... (6 Replies)
I've found a few posts regarding passing parameters to a function or subroutine, but for some reason when I try to run a command based on part with these parameters it's not working. If I have the function echo the parameters they show correctly so I believe they are being passed right but the... (2 Replies)
In a Bash script I used getopts command to let a user does something regards to the selected options. The question is: How do you find out what is the name of the file that user inserted in the command line like the following:
The good part is this file is always the last argument in the... (2 Replies)
Hi,
I have a script which will be executed using the below command,
bin/nutch crawl urls -dir /data/test/
bin/nutch - Script file
crawl, urls, /data/test/ - Parameters
-dir - Option
The above script should executed from a shell script named test.sh. I have the below code to execute... (2 Replies)
Hi,
I have 4 parameters passed to my shell and i validate if all four are entered using the following snippet:
if
then echo "Not entered"
else echo "entered"
fi
I get the following output as 'Not entered even when i enter the values for all prompts.
Please advise.
Thanks. (5 Replies)
Discussion started by: Jesshelle David
5 Replies
LEARN ABOUT MOJAVE
psort_r
PSORT(3) BSD Library Functions Manual PSORT(3)NAME
psort, psort_b, psort_r -- parallel sort functions
SYNOPSIS
#include <stdlib.h>
void
psort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));
void
psort_b(void *base, size_t nel, size_t width, int (^compar)(const void *, const void *));
void
psort_r(void *base, size_t nel, size_t width, void *thunk, int (*compar)(void *, const void *, const void *));
DESCRIPTION
The psort(), psort_b(), and psort_r() functions are parallel sort routines that are drop-in compatible with the corresponding qsort() func-
tion (see qsort(3) for a description of the arguments). On multiprocessor machines, multiple threads may be created to simultaneously per-
form the sort calculations, resulting in an overall faster sort result. Overhead in managing the threads limits the maximum speed improve-
ment to somewhat less that the number of processors available. For example, on a 4-processor machine, a typical sort on a large array might
result in 3.2 times faster sorting than a regular qsort().
RESTRICTIONS
Because of the multi-threaded nature of the sort, the comparison function is expected to perform its own synchronization that might be
required for data physically outside the two objects passed to the comparison function. However, no synchronization is required for the two
object themselves, unless some third party is also accessing those objects.
Additional memory is temporary allocated to deal with the parallel nature of the computation.
Because of the overhead of maintaining multiple threads, the psort() family of routines may choose to just call qsort(3) when there is no
advantage to parallelizing (for example, when the number of objects in the array is too small, or only one processor is available).
Like qsort(3), the sort is not stable.
RETURN VALUES
The psort(), psort_b() and psort_r() functions return no value.
SEE ALSO qsort(3)SEE ALSO sort(1), radixsort(3)
Hoare, C.A.R., "Quicksort", The Computer Journal, 5:1, pp. 10-15, 1962.
Williams, J.W.J, "Heapsort", Communications of the ACM, 7:1, pp. 347-348, 1964.
Knuth, D.E., "Sorting and Searching", The Art of Computer Programming, Vol. 3, pp. 114-123, 145-149, 1968.
McIlroy, P.M., "Optimistic Sorting and Information Theoretic Complexity", Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, January
1992.
Bentley, J.L. and McIlroy, M.D., "Engineering a Sort Function", Software--Practice and Experience, Vol. 23(11), pp. 1249-1265,
November 1993.
STANDARDS
The qsort() function conforms to ISO/IEC 9899:1990 (``ISO C90'').
Mac OS X Nov 25, 2008 Mac OS X