How can I sort a collection of array with different object types in it ?

Hi all,
I have a collection of ArrayList; each array contains, at the first position, the same object type.
I'd like sorting the collection by the name contained in the object at the first position of each array.
Any suggestion ?
Cheers.
Stefano

so you have a collection of a collection?
My guess is that:
You could subclass the arraylist and override it's compareTo method (I think that it implements comparable already but if not, go ahead and implement that interface).
Or you could wrap your arraylist in another class that implements comparable.
The key in my mind is correctly coding your compareTo method to look at the name in the first item of the arraylists. This should be doable and not too difficult.
Correction: after reviewing the ArrayList api, I see that it doesn't implement the Comparable interface. You will have to make any class that either inherits arraylist or contains arraylist implement the comparable interface.
One last thing: This question would probably have been better off in the java forum and not the Swing forum since it doesn't really involve Swing.
Good luck!
Edited by: petes1234 on Nov 19, 2007 6:17 AM

Similar Messages

  • How can I read pdf files from LabVIEW with different versions of Acrobat reader?

    How can I read pdf files from LabVIEW with different versions of Acrobat reader?
    I have made a LabVIEW program where I have possibility to read a PDF document.  When I made this LabVIEW program it was Acrobat Reader 5.0.5 that was installed on the PC. Lather when the Acrobat Reader was upgraded to version 6.0, there was an error when VI tries to launch the LabVIEW program. And Later again when we upgraded to Acrobat Reader 7.0.5 I must again do some changes and rebuild the EXE files again
    It isn't so very big job to do the changes in one single LabVIEW program, but we have built a lot of LabVIEW programs so this take time to due changes every time vi update Acrobat Reader. (We have build EXE files.)
    The job is to right click the ActiveX container and Click "Insert ActiveX Object", then I can brows the computer for the new version of acrobat Reader. After this I must rebuild all the "methods" in the Activex call to make the VI executable again.
    Is there a way to build LabVIEW program so I don't have to do this job every time we update Acrobat Reader?
    This LabVIEW program is written in LabVIEW 6.1, but I se the problem is the same in LabVIEW 8.2.
    Jan Inge Gustavsen
    Attachments:
    Show PDF-file - Adobe Reader 7-0-5 - LV61.vi ‏43 KB
    Read PDF file.jpg ‏201 KB
    Show PDF-file - Adobe Reader 5-0-5 - LV61.vi ‏42 KB

    hi there
    try the vi
    ..vi.lib\platform\browser.llb\Open Acrobat Document.vi
    it uses DDE or the command line to run an external application (e.g. Adobe Acrobat)
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • Using the value "Image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of preconfigured file types (.jpe, .jpg, .jpeg, .?

    On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
    Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
    <input type="file" name="file" accept="image/*" id="file" />
    mimeTypes.rdf does not seem to allow this.

    ''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
    You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
    <pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
    For details, see
    * [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input]

  • How can I sort my collection who bought what.

    Hi All,
    Dilema Music from 3 different users purchased on different apple accounts,all in one Mac, now we all live in seperate places and the music from the other 2 are no longer authorised. I want a way to find only the tracks of those users and delete them form a very large library approx 1.5TB. How can I organise this. So far I have a smart playlist of just "purchased AAC" files but am unable to figure out who bought what, Unless I go thru each item info then delete each one. There has to be a better way......

    Use this script -> Track Down Purchases v1.1
    "This script will examine each track in a selection of tracks or a selected playlist to determine if it was purchased from the iTunes Store and then copies it to a discrete playlist named for the person who purchased it, eg: "Steve Ballmer's Purchased Music". Recognizes song, video, and audiobook purchases. "

  • How can i sort PDF's on IBook with the name that starting with numbers

    i import a number of pdf's representing ameeting agenda as the files names (1xxx,1.1xxxx, 2.xxxx,10.xxxx) on ibook , however the files sorted on a diffrent way as file start with 10 on first . so how can i sor the files on the IBook  with its name starting with numbers as1 &1.1 and so on.

    You seem to want a numeric sort but are getting a character sort.
    a number range  would be 0,1,2,3, ... 9,10,11 ...
    sorting like everything else with computers is an algorithm.  Someone needs to define how it works.  When you see a list of files, someone has defined how the list will be sorted. If you compare Windows file sorting to Mac files sorting you will find there are differences.
    In the case of files sorting, the files are sorted on characters from left to right. In file sorting the sorting algorithm does not try to determine that files are numbers.  All files beginning with a 1 will be sorted together becuase the file sorting althorithm doesn't look at the second character position before grouping all the 1's together.
    For what it is worth, there are multple books written on sorting.
    Robert

  • How can my wife and I share music with different accounts

    My wife is always downloading music.  I would like to add her music to my ipod/iphone etc.  We both have different itunes accounts but share one computer as different users.  Can someone please help me to figure this out?  I don't want to buy music multiple times.  Thank you.
    Windows 7

    iTunes: How to share music between different user accounts ...

  • How can I read a binary file stream with many data type, as with AcqKnowledge physio binary data file?

    I would like to read in and write physiological data files which were saved by BioPac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/ app156Fi
    leFormat/FileFormat.htm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/ app155macffmt/macff.htm).
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, I was a little unsure which LabView data types correspond to int, char , short, long, double, byte, RGB and Rect. And, since it is for PC I am also assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    Two samples *.acq binary files are attach to this post to the list. Demo.acq is for version 3.7-3.7.2, while SCR_EKGtest1b.acq was recorded and saved with AcqKnowledge 3.8.1, which version number is 41.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to i
    llustrate it.
    Many thanks in advance for your help.
    Donat-Pierre
    Attachments:
    Demo.acq ‏248 KB
    SCR_EKG_test1b.acq ‏97 KB

    The reading of double is also straight forward : just use a dble float wired to the type cast node, after inverting the string (indian conversion).
    See the attached example.
    The measure of skin thickness is based on OCT (optical coherent tomography = interferometry) : an optical fiber system send and received light emitted to/back from the skin at a few centimeter distance. A profile of skin structure is then computed from the optical signal.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Read_AK_time_info.vi.zip ‏9 KB

  • How can I read a binary file stream with many data type, as with AcqKnowled​ge physio binary data file?

    I would like to read in and write physiological data which was saved by Biopac�s AcqKnowledge 3.8.1 software, in conjunction with their MP150 acquisition system. To start with, I�d like to write a converter from different physiodata file format into the AcqKnowledge binary file format for version 3.5 � 3.7 (including 3.7.3). It will allow us to read different file format into an analysis package which can only read in file written by AcqKnowledge version 3.5 � 3.7 (including 3.7.3).
    I attempted to write a reader following the Application Note AS156 entitled �AcqKnowledge File Format for PC with Windows� (see http://biopac.com/AppNotes/app156FileFormat/FileFo​rmat.h
    tm ). Note the link for the Mac File format is very instructive too - it is presented in a different style and might make sense to some people with C library like look (http://biopac.com/AppNotes/app155macffmt/macff.ht​m) .
    I guess the problem I had was that I could not manage to read all the different byte data stream with File.vi. This is easy in C but I did not get very far in LabView 7.0. Also, because it is for PC I am assuming the data to be written as �little endian� integer, and thus I also used byte swap vi.
    I would be grateful if you someone could explain how to handle such binary file stream with LabView and send an example to illustrate it.
    Many thanks in advance for your help.
    Donat-Pierre

    One more step...
    short are U16 integer
    double are double precision float
    bool seem to be 2 bytes (= U16)
    char are string (variable length)
    rgb are U16 integer, with high order byte = 0
    rect should be 4 x U16 (top, left, bottom, right)
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • How to move and resize a whole layer with different objects and groups

    Ok, I am a bit confused here.Things are not working like I thought they would and the documentation has confused me more.
    currently in my code I have
    var embedLeftSleeve = new File(folderPath+"/LeftSleeve.ai");
    var leftSleevePlaced = doc.groupItems.createFromFile(embedLeftSleeve);
                            leftSleevePlaced.top = currentHeight;
                            leftSleevePlaced.left = 0;
    I am importing an AI file and trying to put it into its own layer. I want it (the imported ai file) into into it's own layer. And I would like the layer to be setup the exact way it was in the original. But, after the import it seems to group non-grouped items, some of the objects are not showing the same way they did (like a shape with a gradient fill in it).
    And finally, I want to scale all of the items in that layer as if I selected the layerer in illustrator and scaled it by hand (but scripting it to a set scale).
    Can someone please help me. I am digging deep into the documentations and looking all over online to find what I want with little luck.
    John

    Any chance of a sample of your art? I had a quick and my test art does NOT break up or look any different.
    I've been trying to build myself a set of library functions so my methods may appear a little odd.
    This was fine for me…
    #target illustrator
    var sleveArt = new File ('~/Desktop/Untitled-2.ai');
    var artName = sleveArt.name;
    var docRef = app.activeDocument;
    with (docRef) {
    pageOrigin = [0,0];
    rulerOrigin = [0,0];
    var docHeight = height;
    myLayer = layers.add();
    myLayer.name = artName;
    myGroup = myLayer.groupItems.createFromFile(sleveArt);
    myGroup.top = docHeight;
    myGroup.left = 0;
    resizeObject(myGroup, 140, 140, 100, 'BL');
    selection = null;
    function resizeObject(obj, sX, sY, clw, tr) {
    if (verifyObject(obj)) {
    var transAbt = getAnchor(tr);
    obj.resize(sX, sY, true, true, true, true, clw, transAbt);
    return true;
    function verifyObject(obj) {
    if (obj.typename == 'CompoundPathItem'||'GraphItem' || 'GroupItem' || 'PathItem' || 'PlacedItem' || 'PluginItem' || 'RasterItem' || 'SymbolItem' || 'TextFrame') return true;
    else return false;
    function getAnchor(x) {
    var thisTrans;
    switch(x) {
    case 'B' : thisTrans = Transformation.BOTTOM; break;
    case 'BL' : thisTrans = Transformation.BOTTOMLEFT; break;
    case 'BR' : thisTrans = Transformation.BOTTOMRIGHT; break;
    case 'C' : thisTrans = Transformation.CENTER; break;
    case 'DO' : thisTrans = Transformation.DOCUMENTORIGIN; break;
    case 'L' : thisTrans = Transformation.LEFT; break;
    case 'R' : thisTrans = Transformation.RIGHT; break;
    case 'T' : thisTrans = Transformation.TOP; break;
    case 'TL' : thisTrans = Transformation.TOPLEFT; break;
    case 'TR' : thisTrans = Transformation.TOPRIGHT; break;
    return thisTrans;

  • How can we create a Collective search help

    Hi all sap experts,
    How can we create a Collective search help on field “OBJECT” which allows to search tables
    o   ARCH_OBJ
    o   TOJTB (Search help: H_TOJTB)
    on 2 tabs.
    Thanks,
    Basu

    Hi
    1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).
    2) Collective search helps combine several elementary search helps. A collective search help thus can offer several alternative search paths.
    3)An elementary search help defines the standard flow of an input help.
    4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with a collective search help.
    5)A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.
    6)Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in a collective search help, they are expanded to the level of the elementary search helps when the input help is called.
    CREATION:
    Go to SE11  Tcode
    select search help
    give the 'z' search help name and create
    select the selection method ur table name eg : 'mara'
    dialog module 'display value immediately'.
    add the field whatever u want and lpos = 1 and spos = 1 and check import and export parameter.
    where left position when displaying and spos = search position
    and then save and activate ..
    See the links:
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee45446011d189700000e8322d00/content.htm
    pls go through this for search help creation
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    Search Help Exits:
    Re: dynamic values for search help
    Re: Dynamic search  help
    Reward points for useful Answers
    Regards
    Anji

  • How can I copy a Font Book library with "Collections" to my 2nd laptop?

    How can I copy a Font Book library with "Collections" to my 2nd laptop?
    I have a number of fonts (approx. 500) on my work laptop which are sorted to different Collections. I'd like to have a copy of the Font Book library with Collections on the laptop I use at home to work. I'd think there was a more straight forward way to do it, but I haven't found any posts regarding the matter so any help would be appreciated.
    Thanks

    To anyone who is reading this based on needing to copy their Font Book to another machine as I do, there is a way to make a copy of the fonts in Font Book by going to file/export fonts. Keep in mind that you will need to have all the fonts selected (command A) in your "All Fonts" list for them to be exported. You will then have a new folder saved to where ever you chose, with all your Font Book fonts in it.

  • How can I create a variable size array?

    How can I create a variable size array?

    ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
    After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
    Anyway, the answer to your question is, of course:
    Vector v = new Vector();(But you should probably use ArrayList instead of Vector.)

  • How can I sort properties in KM?

    Hi!
    Can someone tell me, how can I sort properties in a table (KM) - for example the propertie modified in the default-Table
    Thanks in advance!
    Emma

    HI,
    You can control the sort property of the KM objects using the Layoutsets. In the layoutsets - > Collection renderer there is a sort property in which you can select a field by which you need to sort.
    Then we need to assign this layoutset to the KM iViews. This will be in the property "Layoutsets" of the iview
    Thanks,
    Mahendran B.

  • How can I sort lines of data (alphabetically) in the new pages 5.0?

    How can I sort lines of data (alphabetically) in the new pages 5.0?
    It was very simple to do in the previou version of pages.

    I'm not sure why people are torturing themselves with Pages 5 given the nearly universal outcry on this forum and the incredibly negative reviews elswhere, such as the App Store.
    Pages 4.3 should still be in an iWorks folder within your Applications folder.  Just use that.
    Please remember to tell Apple what we need from them at:
    http://www.apple.com/feedback/pages.html

  • How can I sort files in a folder by name?

    How can I sort files in a folder by name? iFS first sort files that starts with upper-case letter and then files with lower-case letter.
    Like:
    A_file
    B_file
    a_file
    b_file
    I want:
    A-file
    a_file
    B_file
    b_file
    This doesn't help:
    String[] sort_attributes = {"NAME"};
    boolean [] sort_orders = {true};
    SortSpecification sort = new SortSpecification(sort_attributes, sort_orders);
    currentFolder.setSortSpecification(sort);
    Do I have to get all items in a folder and then sort them?
    /Elin

    I do not think there is a way to do that without add-ons
    There are a couple of workarounds I am aware of
    * Add the bookmarks manually in the bookmarks library and choose the position. That is using Show all bookmarks -> open required folder -> select a position and right click -> add new bookmark <br />Rather a slow and clumsy process
    * Sort a folder and copy it. If you sort the folder contents then copy and paste them they remain in that order when pasted.
    There are add-ons but I have not tried them. For example
    * https://addons.mozilla.org/firefox/addon/simplesort-bookmarks/
    * https://addons.mozilla.org/firefox/addon/auto-sort-bookmarks/
    There will be others available and take note of the advice to backup bookmarks manaully.
    * [[Restore bookmarks from backup or move them to another computer#w_manual-backup]]_manual-backup

Maybe you are looking for