How do you sort vector descendingly?

Lets say if have a vector which contains values in double data type.
Vector vNum = ne wVector();
vNum.addElement(new Double("50.5"));
vNum.addElement(new Double("40.5"));
vNum.addElement(new Double("60.5"));_______________________________________
If you sort it ascendingly by entering the code:
Collections.sort(vNum);The result would be
40.5
50.5
60.5
and it is correct. But i tried to sort it descendingly by entering the code:
Collections.reverse(vNum);The result was:
60.5
40.5
50.5
Someone told me before that the code for sorting descendingly was Collections.reverse(vectorName); but it didnot work.
Does anyone know what's the code for sorting the Vector descendingly?
thanks!

Collections.reverse(list) just reverses the order of the elements in the specified list.
You can either call sort() and then reverse(), or you can specify your own Comparator for sorting in reverse order. (I prefer the second solution)
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List,%20java.util.Comparator)

Similar Messages

  • How do you sort into descending order?

    How do you put your data into a descending/ascending order?

    This is one way (click the disclosure triangle by the column letter to get this contextual menu):
    SG

  • How can you sort photos by descending date in Photos?

    how can you sort photos by descending date in Photos?

    There is no way to do that.
    http://www.apple.com/feedback/macosx.html
    Let Apple know your requirements.

  • Need to show proof of purchase to my insurance company, but my phone was replaced by apple so has a different imei number to the one on my receipt, how do you sort this out??

    Need to show proof of purchase to my insurance company, but my phone was replaced by apple so has a different imei number to the one on my receipt, how do you sort this out??

    Contact Apple and see if they can provide any documentation of the device swap.

  • How do you sort iBooks library by author's  last name

    How can you sort the iBooks library by author's last name. Currently the sort by author uses first name.

    Anyone have a solution to this yet?
    In MUSIC, clicking on columns to add ALBUM name only adds ALBUM by ARTIST which does not give a way to see and sort for the entire LIBRARY.
    Seems to be a lost ffeature in the new 9.0 version.

  • How do you sort photos by face/name on iPad2?

    How do you sort photos by face/name on iPad2?

    iPhoto is designed to work with photos from cameras, and so seeks the date in the Exif metadata that the camera writes to the file.
    There is no way to organise photos by the date they were imported to iPhoto.
    Regards
    TD

  • How do you sort the safari  "Bookmarks Bar" bookmarks

    how do you sort the safari  "Bookmarks Bar" bookmarks

    Here is the workaround for sorting your bookmarks - you don't have to do it manually as suggested in the previous answer here. This is from a 2006 page at Hints.Macworld.com
    "One thing that bugs me is that there is no option in Safari to alphabetize bookmarks. I had a crazy idea about how to accomplish this, and it seems to work. Hopefully I'm not missing something more obvious.
    What I did was open the Bookmarks window (Bookmarks: Show All Bookmarks), put the links I wanted to alphabetize into a folder, and then dragged that folder into the Finder. The Finder alphabetizes the bookmarks; you can then just drag the folder back into the Bookmarks window. You probably have to set the Finder to arrange files by name before it will work. Hope this helps!
    [robg adds: When you drag the folder back, you'll now have two folders, the original and the sorted one. Just delete the original, and you're set. You can also do this without first creating a Safari folder. Just select all the bookmarks to be alphabetized, drag them into a new folder in the Finder, open that folder (make sure it's set to sort by name or use column view), then drag the now-sorted bookmarks back into Safari's Bookmarks window. Again, you'll have duplicates, so just delete the originals (which will be grouped above the newly-placed list). I wonder if any of this is scriptable...]"
    If you're like me and you like to keep all of your bookmarks in folders in the Bookmarks bar, then from the Bookmarks window you would open the Bookmarks Bar in a window of its own before doing the above.

  • How do you sort safari bookmarks

    How do you sort bookmarks in safari? Why does apple not allow you to do this?

    Hi,
    You can manage your Bookmarks anyway you like.
    Start here.  http://www.cultofmac.com/how-to-manage-safari-bookmarks-efficiently-macrx/35616
    If you want to alphabetize a Bookmark folder just move it to your Desktop. The Finder will automatically alphabetize the list of Bookmarks for you then just drag it back to the Safari window.
    Carolyn 

  • How do you sort Pics in Smart Folder? Photos App

    How do you sort pics in a smart folder in the Photos App? Date, Name, etc.

    Yes, when I do that it sorts the albums in the folder by name.
    I may have misused terminology, I meant Smart Albums not smart folders, if this makes a difference.
    Thanks for your help!

  • How do you sort video in itunes

    in itunes you have the video section then you have 4 subsections Movies,Music Videos, Podcasts, and Tv Shows.
    How do you sort the different video in itunes from all vidoes to those subsections

    ben7072 - I just found this on the discussions board: "Under View Options in the View menu, check the box that says Artist. Then rearrange your shows by Artist instead of Show."
    It does work. Obviously, the Artist needs to be the same a Show for it to truly fix our problem here... this is the case for me.
    I'd still like to know what the real problem is though...
    iMac G5   Mac OS X (10.4.9)  

  • How can you sort an album that was released in 2007 but has 80s music on

    I have v8 of iTunes, almost completed all my tagging how I want it in iTunes for all my music
    I have a query though, I have a 80s, 90s smart playlist.
    I have recently got an album that was released in 2007, so the year in my library is 2007, however all the music on that album is from the 80s.
    So can you tag with 2 years, ie Album release date and song release (original date) or can you sort the album to show its songs from the 80s.
    Someone must have the same issue, especially from compilation albums
    please help
    cheers

    ahh, was hoping it may have had a "overall" year or album year release date.
    Man that means I gotta tag a lot of my music with the correct year now then, as the compilation albums I got all tagged form web with year released
    Whats the best way to get the year of the songs then please? is there an easy way? Ive got a lot of songs to do now
    cheers

  • How do you sort specific columns and freeze a header column?

    I'm creating a list of people attending a workshop and would like the first column to be the number of people attending. The first column is the number and that row sorts with the rest, so then my numbers go 1, 9, 5, etc instead of remaining 1-20. Is there a different way for me to determing the number? I put 1 in cell A 2 and then for A 3 I give it a formula A1 + 1 to create the number sequence. I've tried making it a header column and freezing the column, but it still changes.
    thanks,
    Nancy

    Nancy,
    You can search the discussions when you have a specific question, or you can just browse them from time to time to see what there is to be learned. Your question is a little like "How did you learn to be a good cook?" Most of the good home cooks never went to cooking school, but they have had lots of good coaching and lots of experience. Many of the helpers here have been using spreadsheets for so long that they don't remember when they learned a particular trick or method. And, we like to share, so keep the questions coming.
    I keep the Formula Browser in view, and I study the examples for the functions I think I might want to use.
    Regards,
    Jerry

  • How can you sort music by artist in iOS 8.02 ?!

    HOw can music be sorted by the artist in iOS 8.02 !? It only sorts by song title right now.. why not allow us to select how it is sorted.. like every other NORMAL application in the world?!

    Absolutely no help whatsoever.
    IT simply say "if" the More button is available.. then you can have options... well, there is NO More button available?!
    SO.. how do we get this mystical magical 'More' button!?
    AS an aside, iOS 8 IMHO has aTON of little bugs that make it kinky and frustrating to use.

  • How do you separate vectors of a scanned in drawing to Illustrator CS6?

    Hi! So i have drawn a cartoon picture of a man with a mustache. I have scanned in the picture and live traced and cleaned up the image in illustrator. It looks great! However, i now need to make the mustache a separate item from the rest of the drawing. How do separate the vectors so that i have a few pieces of the image instead of just one continuous whole image??

    Ah, Marisa.
    In that case you will have to cut it loose.
    I believe you may (Smart Guides are your friends):
    1) Create a path with a small Stroke Weight, preferably with a rather different Stroke Color (you may use red, magenta, or whatever far from black and white), across each transition where you want the moustache to end; it may be curved or straight, just custom make it so that it ends at the edges of the transition between moustache and the rest (Smart Guides will say path);
    2) With the path still selected, Object>Path>Divide Objects Below.
    If you do that for each transition, you should end up with the moustache as a separate path.
    It is past midnight here (more than an hour after midnight according to the dreadful summer time), so it is high time to attend to other duties, before the sun is up.

  • ITunes 11 - How do you Sort by Genre then Artist? Other General Customizations

    Hello,
    Maybe somebody else knows how to do this, if so please post it. I am really disappointed in iTunes ever since version 10 I think, where they majorly revamped the whole look for it. No, I am not one of those people who are opposed to change and are slow to adapt when changes are made to applications either. I just feel these new changes majorly suck.
    So I am using version 11, the latest one. Apple has made it so uncustomizable that it is ridiculous. Correct me if I am wrong in saying this, that you can’t do any of this stuff anymore. When I open iTunes I like to be able to select Genres and then have the music within the Genre sorted by artist. I don’t see how you can do this anymore. Now when you click on Genre there is no longer an option to sort anything. Everything is sorted by CD Name and you aren’t allowed to sort it any other way. Seriously, who really knows the name of every CD they own, especially when you have several 100 CDs?
    So if I want to view my music by artist I have to select Artists, which that lists all artists (regardless of genre).  I hate this because then it is harder to find the exact artist you are looking for because the list is that much longer and you are scrolling through a ton more artists just to get to the one you are looking for. Yes, I already know there is a search library feature. I also like viewing the artist by Genre because it is easier to determine if the newly added CD was placed in the correct Genre. I know some people just add music and don’t care where it is placed or how it is organized, but I like to keep it all organized. I even have it organized on my computer by folders Genres, folders Artists, and then folders CDs.
    This is the same for viewing your Playlists. You used to be able to select your playlists and then view a specific genre within that playlist. From there I could sort the playlist however I wanted, like by artists, and then CD. I have several playlists that have more than one genre in it. With this new version you can’t view your playlist by genre, you can only view all of the songs within the playlist.
    I also liked in the old version how you could view the number of songs in each genre. Well, you can still do this once you click on the genre, but there isn’t an overview anymore. Like in the old version it would list all the genres and then in a caption underneath each genre it would show how many songs and different artists are in each genre. There was no need to go into each individual genre to view this information. You could also view the number of songs in each genre within each playlist as well.  The playlist thing has been removed altogether. Now you can only view how many songs are in the playlist, regardless of genre.
    The new version does have a few tiny benefits, like easily being able to see what playlist(s) a particular song is in by right clicking on a song and then selecting Show in Playlists. I however, don’t feel the tiny tweaks outweigh the view customizable benefits of previous versions. These new tweaks could have easily been added to the older versions without disabling the customizable view settings.

    Max OSX 10.6.8, iTunes 11.1
    I had a similar problem: I wanted to synch my playlist to my iphone. I like to have my playlist sorted by genre. But under each genre, albums are not sorted by the track numbers. This is a problem, especially when I am listening to club mixes when the DJ smoothly transitions from 1 track sequentially to the next one. Under the properties of each audio file, the Track Numbers and Disc Numbers are already there.
    My perfect solution was to turn On Sorting - Sort Album under View>Show View Options. Then, select all the songs in that album (Shift click, Cmd click, etc) , and Edit multiple item information (Cmd I). You will see Info-Video-Sorting-Options buttons. Click on Sorting. Then, under Sort Album, Enter the name of the album. Then OK.
    You should now have the playlist sorted by Genre, then each album individually sorted by track numbers. On your playlist you should see, if you scroll right, the column added called "Sort Album".
    Hope this helps.

Maybe you are looking for

  • External Monitor for Macbook Pro (Use for Audio)

    Hey Well I have a Macbook Pro and am looking to get an extra monitor because I am an Audio Production major and need the space. I'm looking for about 20-22 inch range and maybe one that swivels so it is horizontal or vertical. Please let me know what

  • External hard drive won't appear on desktop

    I just bought a Western Digital passport 250gb external hard drive and when I plug it into my iBook G4 (version OS 10.4.10) it will not appear (via usb 2.0). I tried plugging it into a macbook and it appeared. Any ideas would be very much appreciated

  • MacBook Pro 17" Santa Rosa and 64-bits strange issue...

    Hi all, my MacBoo Pro 17" Intel Core 2 Duo 2,4GHz under SL 10.6.5 seems to be able to boot in 64 bits, so I edited the com.Apple.boot.plist in order to do so. I rebooted fine but as I'm going to Informations System, it shows that the Kernel didn't bo

  • My iPod keeps saying video playing through tv what does that mean?

    My iPod keeps saying video playing through tv what does that mean and how can I stop it?

  • Expense Account from Organization Parameter

    Hi, I have created an item and unchecked the flag " Inventory Asset Value " from the costing tab in item master and child organization . Problem : when i create a purchase order -- in the distribution window i have chosen the type as " expense" and w