06-17-2010
Arbitrary sort orders
So, suppose I want to sort something in some arbitrary order... for example, let's say I have "grades" (actually, work evaluation results where I work) that are, from best to worst, E, A, S, D, P. So, I want to sort by a "grade" column with the E's first, then the A's, etc. Is there a reasonably straightforward way to create an arbitrary sort order like this? It can be done readily in awk and other languages, but I'm wondering about the sort command itself.
Another application might also be sorting -h output for the ls or du commands-- sort order T, G, M, K, B (or nothing).
6 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello all,
I don't know ksh that well but when I try to run a simple script using the bc command I get "unexpected '.' ", has any one encouter this or help me. I'm running under redaht 7.2. Here is a simple example:
#!/bin/ksh
#
kilo=`echo "2495 * .25"|bc`
if
then
echo "LESS THEN"... (2 Replies)
Discussion started by: larry
2 Replies
2. Shell Programming and Scripting
How do I split a file into unequal line number segments? For example, I have a 100,000 line file that I need to split into 4 or 5 segments and the segments are not uniform, so split will not work in this case. The five segments might be: 27,000 44,512 13,542 2,344 & 12,602.
I can accomplish... (4 Replies)
Discussion started by: sitney
4 Replies
3. UNIX for Advanced & Expert Users
Hello all -
I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies
4. Shell Programming and Scripting
I have a bunch of strings that contain, among the tokens, the size of a file. I want sort based on this value, which is always located in the same "column" in each string, with the largest at the top. Thanks (6 Replies)
Discussion started by: stevensw
6 Replies
5. Shell Programming and Scripting
I have a txt:
a/b/c/d
a/b/c
b/f/g/v/m
I want ot change this txt according to the number of '/'
the result should be like:
b/f/g/v/m
a/b/c/d
a/b/c
how to do that?
Thanks in advance
I need shell...sorry, python or perl is a good solution, but i want shell
Please use code... (8 Replies)
Discussion started by: Henryyy
8 Replies
6. Shell Programming and Scripting
#!/bin/bash
# permutation_combination.sh
# Version: 2.0
# Author : YongYe <complex.invoke@gmail.com>
arg0=-1
argv=${3}
number=${2}
eval ary=({1..${1}})
length=${#ary}
percom(){ nsloop i ${1} number${2} ${3} ${4} ${5}; }
invoke(){ echo $(percom ${argu} nsloop -1) prtcom $(percom... (1 Reply)
Discussion started by: complex.invoke
1 Replies
LEARN ABOUT MOJAVE
slapo-valsort
SLAPO-VALSORT(5) File Formats Manual SLAPO-VALSORT(5)
NAME
slapo-valsort - Value Sorting overlay to slapd
SYNOPSIS
/etc/openldap/slapd.conf
DESCRIPTION
The Value Sorting overlay can be used with a backend database to sort the values of specific multi-valued attributes within a subtree. The
sorting occurs whenever the attributes are returned in a search response.
Sorting can be specified in ascending or descending order, using either numeric or alphanumeric sort methods. Additionally, a "weighted"
sort can be specified, which uses a numeric weight prepended to the attribute values. The weighted sort is always performed in ascending
order, but may be combined with the other methods for values that all have equal weights. The weight is specified by prepending an integer
weight {<weight>} in front of each value of the attribute for which weighted sorting is desired. This weighting factor is stripped off and
never returned in search results.
CONFIGURATION
These slapd.conf options apply to the Value Sorting overlay. They should appear after the overlay directive.
valsort-attr <attribute> <baseDN> (<sort-method> | weighted [<sort-method>])
Configure a sorting method for the specified attribute in the subtree rooted at baseDN. The sort-method may be one of alpha-ascend,
alpha-descend, numeric-ascend, or numeric-descend. If the special weighted method is specified, a secondary sort-method may also be
specified. It is an error to specify an alphanumeric sort-method for an attribute with Integer or NumericString syntax, and it is an
error to specify a numeric sort-method for an attribute with a syntax other than Integer or NumericString.
EXAMPLES
database bdb
suffix dc=example,dc=com
...
overlay valsort
valsort-attr member ou=groups,dc=example,dc=com alpha-ascend
FILES
/etc/openldap/slapd.conf
default slapd configuration file
SEE ALSO
slapd.conf(5), slapd-config(5).
ACKNOWLEDGEMENTS
This module was written in 2005 by Howard Chu of Symas Corporation. The work was sponsored by Stanford University.
OpenLDAP 2.4.28 2011/11/24 SLAPO-VALSORT(5)