How to sort a list with numbers?

Hi!
How do i sort a list like this:
["Amningsnapp 6.c", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]
...so that I get a list in number order like this instead:
["Hår Gummisnodd 1.c","Pincett 2.a","Protes Rengöring 3.a","Sprayflaska Plast 4.b","Barn/Baby Underjams Girls 5.b","Anti-Colic Nappflaska 6.b","Amningsnapp 6.c","Leksaker 7.a"]
On mouseUp
currentItem = the mouseLine
  if the doubleClick = TRUE then
    handlingslista.add (field(12).line[currentItem])
    sort handlingslista
    set x = count (handlingslista)
    repeat with i = 1 to x
      put handlingslista[i] into member(17).line[i]
    end repeat
  end if
end
--This is what the list handlingslista contains:
["Amningsnapp 6.b", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]

Assuming the number always occurs as the last word, you could temporarily store the items in the form ["6.c", "Hår Gummisnodd 1.c"], therefore resulting them being sorted lexicographically based on the last word, like this:
handlingslista = ["Amningsnapp 6.c", "Anti-Colic Nappflaska 6.b", "Barn/Baby Underjams Girls 5.b", "Hår Gummisnodd 1.c", "Leksaker 7.a", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b"]
repeat with n = handlingslista.count down to 1
  handlingslista[n] = [the last word of handlingslista[n], handlingslista[n]]
end repeat
handlingslista.sort()
repeat with n = handlingslista.count down to 1
  handlingslista[n] = handlingslista[n][2]
end repeat
put handlingslista
-- ["Hår Gummisnodd 1.c", "Pincett 2.a", "Protes Rengöring 3.a", "Sprayflaska Plast 4.b", "Barn/Baby Underjams Girls 5.b", "Anti-Colic Nappflaska 6.b", "Amningsnapp 6.c", "Leksaker 7.a"]
Alternatively, you could use Javascript, in which Arrays can be sorted based on an arbitrary ordering: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort.

Similar Messages

  • How to sort a list of strings, without methods and stuff just simple code?

    Hi
    How to sort a list of strings, without methods and stuff just simple code?
    Thanks in adavance!!

    Without methods? How are you going to all the sort code? What is the point of code?
    Collections.sort(List) will sort strings or anything that implements the Comparable interface, or you can use the sort method that takes a Comparator implemenation.
    If you want "just code", you could either get the Collections class souce and follow it to the code. But otherwise, there isn't one set of code. There are various sorting algorithms with advantages and disadvantages. Maybe you'd be better off searching for sorting algorithms and if you understand them, it should be simple to write Java implementations of them.

  • How to Edit Contact List with email

    How to Edit Contact List  with email ID  in the heading
    Regards,
    Charles.KE

    eh? Can you please give some detail of what you're attempting to do ?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to create a list with customised listItem

    I want to create a list with 2 icons and text. I want to display one icon at the left, one icon to the right and text at center. Everytime my icon images might change. I want to know how create this type of list.

    Ok, I managed to create a Text Bullet "Chapter" in level 1 but how can I join the numbering at level 2 on the same line ?
    Pierre

  • How to sort file list by time

    I have saved many PDF files from my mails - when I want to open (Adobe Reader on Samsung tablet) the file last saved I have no possibility find it simply by sorting file list by time - (list is fixed by name only) - how to change list order?.

    Sorting by time could be based on documents'
    (a) Date/Time created
    (b) Date/Time modified
    (c) Date/Time last opened / accessed
    Adobe Reader for Android shows (c) in Recents.
    (Click the image above to enlarge)
    The last opened PDF document appears at the top.  Please note that it is not customizable - meaning that you (as a user) cannot change the sorting criteria.

  • How to fix "Select List with Submit" Problem

    I have a report with two regions. Region1 has a list item which is set to "Select List with Submit". Based on the list/item value selected in the Region1, the data is displayed in the Region 2.
    Question: How do I ge the report, Region2, to have the data populated based on the first value in the list when the page is loaded - for the first time. Currently, when the page is accessed, the list has the first value selected in the Region1 list item by default, but the Region2 is blank.
    DP
    Edited by: user4115675 on Jan 14, 2010 9:37 AM

    Earl, please see the response in italics for each of your questions below:
    You do want your default value to be one of the values in the select list. Otherwise why would you want the value there at all?
    So, then should I have a default value at all? And, if yes, then what should it be?
    And can't you just set the default value to the first value in your select list, whatever that is, so the first value is the selected value?
    I did that and it works, only if the first value in the select list is always going to be there.  The select list is based on a column data in a table.  And if the data for that column changes then the values in the select list will change.  And, the first value might not always be the same.
    I guess I'm not clear why this isn't doing what you want, besides the fact that
    you seemed to have removed the default value from the dynamic select list query, which you shouldn't do.
    I removed the first value (it could have been any values) from the select list to mimic the "dynamic" select list -- just to test.  The select list data is based on a table and the data in the table can change.
    Thanks
    DP

  • Received an exel document; how do I open it with Numbers format?

    received an Excel document; how do I open it in Numbers format?

    Use the menu item "File > Open...":
    Then navigate to, and select, the file

  • How to Fix Select list with redirect Problem

    Hi
    I have a field F1 of type select list with redirect.
    It has an LOV with 2 values USA and Canada for eg..
    I choose USA and hit save and saved it to DB..
    now f1 is stored in table with my User ID and value is USA.
    when I log in next into this page,
    this field should show me the value USA.
    But its not happeneing for me..it always gives the null value when i re login
    is there a way to default/source it to my value??
    I am using
    select f1 from table
    where user_id=:user_id;
    i checked and this query works in sql plus...

    Earl, please see the response in italics for each of your questions below:
    You do want your default value to be one of the values in the select list. Otherwise why would you want the value there at all?
    So, then should I have a default value at all? And, if yes, then what should it be?
    And can't you just set the default value to the first value in your select list, whatever that is, so the first value is the selected value?
    I did that and it works, only if the first value in the select list is always going to be there.  The select list is based on a column data in a table.  And if the data for that column changes then the values in the select list will change.  And, the first value might not always be the same.
    I guess I'm not clear why this isn't doing what you want, besides the fact that
    you seemed to have removed the default value from the dynamic select list query, which you shouldn't do.
    I removed the first value (it could have been any values) from the select list to mimic the "dynamic" select list -- just to test.  The select list data is based on a table and the data in the table can change.
    Thanks
    DP

  • How create LOV(select List) with all LDAP users

    Hello,
    I am trying to create a selected list with all the users in my LDAP, note my LDAP is synchronized with my OID.
    Any suggestions, I'm searching the the pl/sql statment?
    Thanks
    Hussam

    Hi Hussam,
    Take a look at my comments in the following two threads -
    Re: LDAP
    Re: Cookie And LDAP
    The two different threads discuss the methods I use to do what you want to do (so you really need to 'combine' the two different threads).
    Hope this helps

  • How to create a list with "Chapter" before the numbering ?

    Hello Apple Support Communities.
    I would like to create a automatic list in Pages with "Chapter" or "Part" set before the numbering.
    Exemple:
              Chapter 1. Blabla
                   Part A. Blabla
              Chapter 2. Blabla
    Thanks

    Ok, I managed to create a Text Bullet "Chapter" in level 1 but how can I join the numbering at level 2 on the same line ?
    Pierre

  • How do I save as with Numbers 2.1 Lion version

    ok so I've been a user for about 6 months. Moved to Lion OS X and now the "Save as" option is missing. So if I have a spreadsheet that I want to keep but modify and call something else aka using the "save as" how do I now do this?

    NO, NO and NO !
    Save a version doesn't give the ability to change a name. It doesn't open a dialog. This is why there is no ellipsis at the end of the menu item.
    It allow us to save the changes applied to a document in the hidden folder folder
    “.DocumentRevisions-V100” which exists at the root level of every volume connected to a machine running Lion.
    Save… allow us to save a document which was never saved before. The ellipsis means that the feature open a dialog.
    Duplicate create a replicate of the current document giving it a default name based of the name of the original minus the extension (.numbers). On a French system a replicate of azerty.numbers is named azerty - copie.
    One more time the, good old rule apply : no ellipsis = no dialog.
    If you don't believe me,
    create a doc and save it as azerty.numbers.
    Type B2 in cell B2
    Save a Version
    remove the contents of the cell B2
    Save a Version
    Type OK in the cell B2
    Close the document
    Re open it.
    The doc will contain OK in the cell B2 and, if you look at the versions available you will see at least one with OK in B2,
    one with nothing in B2
    one with B2 in B2
    If you have an external device, HD or memory stick, copy the document to the external device then open it.
    It will contain OK in B2 but will no longer have access to the versions.
    Saving a version saves nothing in the doc itself.
    What save datas in a doc are :
    the initial Save which create the file on disk
    the automatic autosaves
    the close action which in fact execute three tasks:
    (1) save the document
    (2) save a version matching the last state
    (3) close the doc.
    I put 'save the document' at 1st position but honestly I don't know if the system save the file before saving the late version or if it save the late version before saving the file.
    I will try to describe every cases
    (A) open an existing document
    trigger Save a Version
    you will not be able to give a new name.
    (B) open an existing document
    trigger Duplicate.
    you will get a window entitled oldname - copy
    look at the file menu, there is no "Save a Version" item but a "Save…" one
    Trigger "Save…" This time you may edit the name and the location.
    After that, you will be allowed to trigger Save a Version for both documents but this will add nothing to the docs themselves.
    It's really important that it behave this way.
    (a) it would be a bit annoying to send a file to a correspondant with the different intermediate versions embedded.
    (b) Apple failed to deliver the required tools but I built a set of three scripts giving up the ability to extract the versions, even if the main document is corrupted. This way, assuming that you worked during two hours on a doc saving a version every ten minutes, and that two days after Numbers prove to be unable to re-open its own creation (not a rare behavior).
    With my script, you will be able to extract the different versions stored in “.DocumentRevisions-V100”
    Maybe the more recent will be unreadable but the one before will be readable so you will recover quite all your document.
    More, as I never got explanations of the scheme corrupting the files (except when two users try to work simultaneously on a document stored on a network) it's not impossible to have a corrupted main document and a correct 'late version" in the “.DocumentRevisions-V100” folder.
    Yvan KOENIG (VALLAURIS, France) jeudi 3 novembre 2011 22:18:31
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How to display ALV list with more than 1 structure?

    Hello everyone,
    I am using REUSE_ALV_LIST_DISPLAY to generate a report that displays vendor/customer items with purchases/sales total. I have 2 internal table for this. For every vendor/customer i need a total table right after, this have a different structure. I cannot use REUSE_ALV_BLOCK_LIST_ as this is not capable of calculating the subtotal per currency and from the documentation it says do not use.
    Any idea on how to proceed?
    Thanks!

    Call ALV list function module per table structure.
    Closing this thread.

  • How to use array list with fixed values to insert record in trigger

    I have a list  of number 1,30,40,45,60 . These numbers are not being changed so I  don't need to keep in a table. So have to create a  after insert trigger   for 
    As
    Begin
    @list =  1,30,40,45,60 // Array value 
    for i=1 to @list.count
    Insert into mappingtable(arrayvalue,itemcode) values (list[i],Inserted.Itemcode)
    Next
    End
    Please can you help with a code 
    Regards
    Pol
    polachan

    Be careful what you assume - rarely are lists of values like this truly static.  One thing to keep in mind that arrays in sql server are tables.  So, one example is:
    set nocount on;
    /* represents the virtual inserted table in your trigger */
    declare @inserted table (itemcode char(4));
    insert @inserted (itemcode) values ('ABCD'), ('JJKL');
    select * from @inserted;
    select * from @inserted cross join (values (1), (30), (40), (45), (60)) as arrayx(value);

  • How to Link a list with a Calendar View?

    Hi,
    I currently have a Calendar which is used for Annual Leave. All events that are approved go into a Leave Tally View which i am trying to link with another List called Leave Entitlement so i can then create a column within the Leave Entitlement for a
    calculated field that subtracts the Leave they have a year from how many they have taken so they know how many days they have left.
    Basically how can i create a type of 'Look up' column which takes the amount of days they have taken (from the Leave Tally) and puts it into the correct column for each user within the 'Leave Entitlement' List.
    Really Stumped so any help would be appreciated :)

    Hi Noodles
    (Love the name btw).
    The first thing I'd ask is why link to another list?  You can create non-calendar views (normal lists views) and consider using a workflow both changes the value of the days remaining column and sets the item level permissions to that particular member
    of staff.  Unless there's a specific reason for having the leave entitlement number in a different list?
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • How to get PO list with mark archived or not?

    Hi experts,
    I have a list of POs from both database and archive server using standard report ME2N but I can't distinguish between archived PO or not.
    Actually if I checked the detail PO I could see if it was from archive or not, but this way takes time.
    Please advise how to get list of PO with mark from archive or database.
    Thanks.
    rob

    hi
    u can use me82
    or in me2n us the scope as ARCHIV
    regards
    kunal

Maybe you are looking for

  • Basic Design Question - Firewall Router segment

    I'm at a new place and have to re-do the current lan.  Small office, 80-100 users. Existing setup is flat network, no QoS, no VLANs.  I have already replaced an older PIX with a new ASA (5525x) and added a DMZ.   I am currently trying to draw up a pr

  • Can't delete email with a 9 mb attachment from iphone

    can't delete email with a 9 mb attachment from iphone(3gs, software v 4.3.1) -- every time i try to delete the email with a swipe it shows the red delete button on the right but then freezes for a while and then the delete button disappears but the e

  • How can i get rid of my .me account but still have my .icloud account?

    for some reason i keep getting unwanted email from a bunch of different people sent to my .me email account. i would like to know if i can close it and just use my .icloud account. i dont want to restart with a new email account due to the fact the a

  • Footer doesn't lock at the bottom of the page.

    Here's my draft.  What am I doing wrong? http://morganyatesstudiosalon.businesscatalyst.com/index.html

  • Please Clarify the Errors (Case Structure)

    I am using numeric case structure but I don't understand the errors, can anyone clarify what they are mean and what I have to do to change it. Thank you in advance.