Ask a Question related to Adobe Indesign Windows, Design and Development.

  1. #1

    Default sort

    Hi,

    I want to write a perl script to do something like this



    Abc 12.8 8 "left" 1 15.7

    Def 13.8 9 "top" 0 19.7

    gef 14.8 9 "left" 0 19.7

    Dgf 12.3 9 "right" 4 99.6

    cef 16.8 4 "right" 0 89.7

    baf 32.8 7 "bottom" 5 79.8

    efg 16.8 5 "right" 0 56.7

    etg 12.8 2 "left" 7 34.7





    Just say I want to sort the row based on the value on fifth or third column, any advice how to do so?





    Thank you & best regards,

    ABC




    Boon Chong Ang Guest

  2. Similar Questions and Discussions

    1. [ANN] Sort::Key 0.02
      Hi, I have released Sort::Key 0.02, a module for sorting objects by some key. It's really fast, usually much faster than perl core sort...
    2. Sort by id
      Now I simple forum by Dreamweaver i use "repeat region" for show data in database . It show like this 1 2 3 4 but i want to show
    3. Sort bug
      It appears that the runtime cannot sort a datagrid column when the items in the column contain a NaN or Infinity. Is there a way to override the...
    4. memory sort and disk sort
      I check the sysprofile table and find there are 700 times disk sort, I think it is lack of sort memory. I want to turn all the disk sort into the...
    5. Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB.
      Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. hi, guys i have asp...
  3. #2

    Default RE: sort

    I have to run, otherwise I would elaborate a bit.

    The code is below. Check out the "perldoc perlreftut" for what the
    "\@cols", "@{$row}", and "$a->[2]" means. Check out "perldoc -f sort" for
    what the "sort {...} @rows" means. And of course ask questions if you get
    stuck (but take a look at the docs first).

    ############ THE CODE ############

    my @rows;

    while (my $line = <DATA>) {
    chomp($line);
    my @cols = split(/\s+/, $line);
    push @rows, \@cols;
    }

    print "Sorted on 5th column:\n";
    @rows = sort {$a->[4] <=> $b->[4]} @rows;

    foreach my $row (@rows) {
    print "@{$row}\n";
    }

    print "Sorted on 3rd column:\n";
    @rows = sort {$a->[2] <=> $b->[2]} @rows;

    foreach my $row (@rows) {
    print "@{$row}\n";
    }

    __DATA__
    Abc 12.8 8 "left" 1 15.7
    Def 13.8 9 "top" 0 19.7
    gef 14.8 9 "left" 0 19.7
    Dgf 12.3 9 "right" 4 99.6
    cef 16.8 4 "right" 0 89.7
    baf 32.8 7 "bottom" 5 79.8
    efg 16.8 5 "right" 0 56.7
    etg 12.8 2 "left" 7 34.7

    ############ THE OUTPUT ############

    $ perl sort.pl
    Sorted on 5th column:
    efg 16.8 5 "right" 0 56.7
    Def 13.8 9 "top" 0 19.7
    gef 14.8 9 "left" 0 19.7
    cef 16.8 4 "right" 0 89.7
    Abc 12.8 8 "left" 1 15.7
    Dgf 12.3 9 "right" 4 99.6
    baf 32.8 7 "bottom" 5 79.8
    etg 12.8 2 "left" 7 34.7
    Sorted on 3rd column:
    etg 12.8 2 "left" 7 34.7
    cef 16.8 4 "right" 0 89.7
    efg 16.8 5 "right" 0 56.7
    baf 32.8 7 "bottom" 5 79.8
    Abc 12.8 8 "left" 1 15.7
    Dgf 12.3 9 "right" 4 99.6
    Def 13.8 9 "top" 0 19.7
    gef 14.8 9 "left" 0 19.7


    -----Original Message-----
    From: Boon Chong Ang [mailto:BCANG@altera.com]
    Sent: Thursday, January 29, 2004 7:38 PM
    To: [email]beginners@perl.org[/email]
    Subject: sort


    Hi,

    I want to write a perl script to do something like this



    Abc 12.8 8 "left" 1 15.7

    Def 13.8 9 "top" 0 19.7

    gef 14.8 9 "left" 0 19.7

    Dgf 12.3 9 "right" 4 99.6

    cef 16.8 4 "right" 0 89.7

    baf 32.8 7 "bottom" 5 79.8

    efg 16.8 5 "right" 0 56.7

    etg 12.8 2 "left" 7 34.7





    Just say I want to sort the row based on the value on fifth or third column,
    any advice how to do so?





    Thank you & best regards,

    ABC



    Rob Hanson Guest

  4. #3

    Default Sort

    Does anyone know if there is a way to sort alphabetically in InDesign using the Windows platform?

    Do you need to write special scripting for it?
    Trevor_Slette@adobeforums.com Guest

  5. #4

    Default Re: Sort

    Hi Trevor--

    There's a script on your InDesign CD (or on the first extras CD, if you're using the Creative Suite set) called SortParagraphs.js that might do what you want. It's very slow with large amounts of text, but works well when you need to sort 50 or fewer paragraphs.

    Thanks,

    Ole
    Olav_Kvern@adobeforums.com Guest

  6. #5

    Default sort

    I have the report.cfm page to display all the record from the database. On the
    column header for NAME and T_date I want able to give the user option to sort
    by NAME for ascending or descending OR sort by T_date for ascending or
    descending by click on the little A->Z or Z-->A image. My code below is only
    work for firstpage. Please review the attached code and tell me what did I do
    wrong here or anyone has any good example to point to.

    Thanks
    ================================


    <CFPARAM NAME="sort" default="1 desc">

    <cfquery name="get_distance_name" datasource="#db#">
    select lastname, firstname, t_date, state
    from view_t_report
    order by #sort#
    </cfquery>

    <cfset OnEachPage=50>
    <cfset NumPages=Ceiling(get_distance_name.RecordCount / OnEachPage)>
    <table width="700" cellpadding="0" cellspacing="0" border="1">
    <cfoutput>
    <tr>
    <th width="255" scope="col" class="r_text">Name&nbsp;&nbsp;
    <a href="report.cfm?sort=#URLEncodedFormat("1
    asc")#&PageNum=#DecrementValue(PageNum)#"><img src="../images/ascending.gif"
    alt="Sort by Last Name Ascending" border="0" ></a>
    &nbsp;&nbsp;&nbsp;<a href="terminations.cfm?sort=#URLEncodedFormat("1
    desc")#"><img src="../images/descending.gif" alt="Sort by Last Name Descending"
    border="0" ></a>
    </th>
    <th width="260" scope="col" class="r_text">T_Date&nbsp;&nbsp;
    <a href="report.cfm?sort=#URLEncodedFormat("2 asc")#"><img
    src="../images/ascending.gif" alt="Sort by T_Date Ascending" border="0" ></a>
    &nbsp;&nbsp;&nbsp;<a href="terminations.cfm?sort=#URLEncodedFormat("2
    desc")#"><img src="../images/descending.gif" alt="Sort by T_Date Descending"
    border="0" ></a>
    </th>
    <th width="64" scope="col" class="r_text">State</th>
    </tr>
    </cfoutput>

    <tr>
    <td scope="row" class="#class1#">#UCASE(lastname)#,#Ucase(firstnam e)#
    #Ucase(middlename)#</td>
    <td class="#class1#">#dateformat(t_date,'mm/dd/yyy')#</td>
    <td class="#class1#">#status#</td>
    </tr>
    </cfoutput>
    </table>

    kt03 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139