Is this "order priority" supposed to be an array?  If so, something like
this would work.  It assumes that the priorities start with "1" and there
are no numerical gaps.

<@ASSIGN local$changedIdentifier VALUE="e">
<@ASSIGN local$newPriority VALUE="4">
<@ASSIGN local$priorityArray VALUE=<@ARRAY VALUE="a,1;b,2;c,3;d,4;e,5;">>

<@! "change priority of c to 4">
<@ROWS ARRAY="local$priorityArray">
   <@IFEQUAL "<@COL 1>" "@@local$changedIdentifier">
      <@ASSIGN local$oldPriority VALUE="<@COL 2>">
      <@ASSIGN local$priorityArray[<@CURROW>,2] VALUE="@@local$newPriority">
      <@BREAK>
   </@IF>
</@ROWS>

<@! "resort the priority array">
<@SORT ARRAY="local$priorityArray" COLS="2">

<@! "change priorities of all identifiers between c's old priority and c's
new priority">
<@IF "@@local$newPriority < @@local$oldPriority">
   <@ASSIGN local$step VALUE="1">
<@ELSE>
   <@ASSIGN local$step VALUE="-1">
</@IF>
<@ROWS ARRAY="local$priorityArray" START="@@local$newPriority"
STOP="@@local$oldPriority" STEP="@@local$step">
   <@IF "'<@COL 1>' != '@@local$changedIdentifier'">
      <@ASSIGN local$priorityArray[<@CURROW>,2] VALUE="<@CALC '<@COL 2> +
@@local$step'>">
   </@IF>
</@ROWS>

<@! "verify the priority array is in the correct order">
<@SORT ARRAY="local$priorityArray" COLS="2">


Joanna Ruth Wirtz
Internet Applications Programmer
Christianity Today International

www.ChristianityToday.com

----- Original Message -----
From: "Peter Fogg" <[EMAIL PROTECTED]>
To: "Multiple recipients of list witango-talk" <[EMAIL PROTECTED]>
Sent: Thursday, May 30, 2002 11:48 AM
Subject: Witango-Talk: Sort and Renumber question


> I am sure I am just being retarded but I am having problems with something
> that I thought would be relatively simple.
>
> I have a list of objects
>
> Identifier Original Order Priority
> a 1
> b 2
> c 3
> d 4
> e 5
> changed the priority of c to 4 Identifier New Order Priority
> a 1
> b 2
> c 4 <- changed to 4
> d 4
> e 5
> I want to then renumber the priority Identifier Final Order Priority
> a 1
> b 2
> d 3 <- modified the priority
> c 4 <- now in proper order
> e 5
>
> This is what I want to do. I hope this is clear enough, if not yell at me.
I
> want the item with a new priority to bump the item with its matching
> criteria up.
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>                 with unsubscribe witango-talk in the message body
>


________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to