Sponsored Content
Top Forums Shell Programming and Scripting Sort a bunch of strings by an arbitrary token Post 302533439 by stevensw on Thursday 23rd of June 2011 04:17:44 PM
Old 06-23-2011
Sort a bunch of strings by an arbitrary token

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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort() array of strings in perl

I have a perl script with an array of clients. @arr = ("The ABC Corp", "AA Corp.", "BB Corp"); If I run @a = sort (@arr); I will get @a = ("AA Corp", "BB Corp", "The ABC Corp"); but I want @a = ("AA Corp, "The ABC Corp", "BB Corp"); How do I sort array without changing... (2 Replies)
Discussion started by: photon
2 Replies

2. Shell Programming and Scripting

how to sort strings by length?

I'm trying to find the longest word in /usr/share/dict/words The first thing I can think of is to sort the content by length then it would be easy to find out, but then i realize theres no option of sort to sort by length. Could you guys please give me some help?:confused: (7 Replies)
Discussion started by: rockbike
7 Replies

3. Programming

Sort ascending n strings in C

Hy guys. My English is not so good, sorry for any mistakes. I'm a bigginer in C, and I have a problem. I want to sort ascending n strings, but I can't read the strings. Here is what I've done so far: //sort ascending n strings #include <stdio.h> int main() { int n,i,j; char a; ... (8 Replies)
Discussion started by: 1/0
8 Replies

4. UNIX for Dummies Questions & Answers

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... (2 Replies)
Discussion started by: treesloth
2 Replies

5. UNIX for Dummies Questions & Answers

How to sort lines by strings between ()?

Hello,everyone. I am learning some Info commands.I put all commands and their explanations in a file. This is a part of it: ESC PgUp (scroll-other-window-backward)Scroll the other window backward ESC Right (forward-word) Move forward a word ESC r (move-to-window-line) ESC TAB... (3 Replies)
Discussion started by: vic005
3 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Want to sort a file which contains alphanumeric strings

I want to sort a file which contains alphanumeric string. bash-3.00$ cat abc mtng1so mtng2so mtng11so mtng9so mtng23so mtng7so hstg2so hstg9so hstg1so hstg11so hstg13so bash-3.00$ Want output like this, using one liner. hstg1so (1 Reply)
Discussion started by: Raza Ali
1 Replies

8. Shell Programming and Scripting

Sort strings with numbers

I want to sort my data first by the 2nd field then by the first field. I can't use sort -V because I don't have gnu sort and cannot install one. How do I go about this? Input: G456 KT1 34 K234 KT10 45 L2 KT2 26 H5 LAF2 28 F3 LAF2 36 Output: G456 KT1 34 L2 KT2 26 K234 KT10 45 F3... (14 Replies)
Discussion started by: aydj
14 Replies

9. Shell Programming and Scripting

Sort strings containing numbers

How can I sort this, first by 2nd field then by 1st field. tried sort -b -k 2,2 Input: AS11 AB1 BD34 AB10 AF12 AC2 A345 AB10 R134 AB2 456 AC10 TTT2 BD12 desired output: AS11 AB1 R134 AB2 A345 AB10 BD34 AB10 AF12 AC2 456 AC10 TTT2 BD12 (2 Replies)
Discussion started by: aydj
2 Replies

10. UNIX for Beginners Questions & Answers

Strange results from 'strings | sort'

Using the 'strings' command and piping the result to 'sort' is producing strange results. I get block of lines that begin with asterisks, then a block that begins with some text, then more lines that begin with asterisks. The actual content is correct - lines beginning with asterisks is the... (5 Replies)
Discussion started by: edstevens
5 Replies
Prima::DetailedList(3)					User Contributed Perl Documentation				    Prima::DetailedList(3)

NAME
Prima::DetailedList - a multi-column list viewer with controlling header widget. SYNOPSIS
use Prima::DetailedList; my $l = $w-> insert( 'Prima::DetailedList', columns => 2, headers => [ 'Column 1', 'Column 2' ], items => [ ['Row 1, Col 1', 'Row 1, Col 2'], ['Row 2, Col 1', 'Row 2, Col 2'] ], ); $l-> sort(1); DESCRIPTION
Prima::DetailedList is a descendant of Prima::ListViewer, and as such provides a certain level of abstraction. It overloads format of items in order to support multi-column ( 2D ) cell span. It also inserts Prima::Header widget on top of the list, so the user can interactively move, resize and sort the content of the list. The sorting mechanism is realized inside the package; it is activated by the mouse click on a header tab. Since the class inherits Prima::ListViewer, some functionality, like 'item search by key', or "get_item_text" method can not operate on 2D lists. Therefore, mainColumn property is introduced, that selects the column representing all the data. API
Events Sort COLUMN, DIRECTION Called inside sort method, to facilitate custom algorithms of sorting. If the callback procedure is willing to sort by COLUMN index, then it must call "clear_event", to signal the event flow stop. The DIRECTION is a boolean flag, specifying whether the sorting must be performed is ascending ( 1 ) or descending ( 0 ) order. The callback procedure must operate on the internal storage of "{items}", which is an array of arrays of scalars. The default action is the literal sorting algorithm, where precedence is arbitrated by "cmp" operator ( see "Equality Operators" in perlop ) . Properties columns INTEGER Governs the number of columns in items. If set-called, and the new number is different from the old number, both items and headers are restructured. Default value: 0 headerClass Assigns a header class. Create-only property. Default value: "Prima::Header" headerProfile HASH Assigns hash of properties, passed to the header widget during the creation. Create-only property. headerDelegations ARRAY Assigns a header widget list of delegated notifications. Create-only property. headers ARRAY Array of strings, passed to the header widget as column titles. items ARRAY Array of arrays of scalars, of arbitrary kind. The default behavior, however, assumes that the scalars are strings. The data direction is from left to right and from top to bottom. mainColumn INTEGER Selects the column, responsible for representation of all the data. As the user clicks the header tab, "mainColumn" is automatically changed to the corresponding column. Default value: 0 Methods sort [ COLUMN ] Sorts items by the COLUMN index in ascending order. If COLUMN is not specified, sorts by the last specified column, or by #0 if it is the first "sort" invocation. If COLUMN was specified, and the last specified column equals to COLUMN, the sort direction is reversed. The method does not perform sorting itself, but invokes Sort notification, so the sorting algorithms can be overloaded, or be applied differently to the columns. AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>. SEE ALSO
Prima, Prima::Lists, Prima::Header, examples/sheet.pl perl v5.14.2 2009-02-24 Prima::DetailedList(3)
All times are GMT -4. The time now is 05:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy