Displaying a HashSet in alphabetical order

I neded to display a HashSet in alphabetical order,but only display those words beginning with 'a','h','m' - both lower and upper case. Can someone give me a clue?

Not the most efficient, but simple...import java.util.*;
public class Test {
    public static void main(String[] args) {
     String[] data = {
               "Tango","Uniform","Victor","Whiskey","Xray","Yankee",
               "November","Oscar","Papa","Quebec","Romeo","Sierra",
               "Mike","Zulu",
               "Alpha","Bravo","Charlie","Delta","Echo","Foxtrot",
               "Golf","Hotel","India","Juliet","Kilo","Lima"
     char[] letters = {'a','h','m'};
     HashSet hs = new HashSet();
     // initialize hashset
     for (int i=0; i<data.length; i++) hs.add(data);
     // extract to array
     Object[] hsArray = hs.toArray();
     // sort array
     Arrays.sort(hsArray);
     // print matching items
     for (int i=0; i<hsArray.length; i++) {
     char c = Character.toLowerCase(((String)hsArray[i]).charAt(0));
     for (int j=0; j<letters.length; j++) {
          if (letters[j]==c) {
          System.out.println(hsArray[i]);
          break;

Similar Messages

  • All my folders display in finder in alphabetical order a to z. However when I add a file as an attachment to an email the window that opens for me to select the folder from now displays them in alphabetical order from z to a. How can I alter it? Thank you

    All my folders in finder show as in alphabetical order a to z. However, when I access them because I want to attach one to an email they display as z to a. How can I change this? it's been annoying me for ages. Many thanks.

    When you add an attachment and you open a window to locate it, click on the little arrow I've indicated on the image and it should re-organise them as you want:

  • My iPod Classic is no longer displaying my songs in alphabetical order.  How do I get it to organize the songs again?

    There is some kind of organization that it's using, but I don't know what that organization is.  It displays like fifty songs in alphabetical order (not songs by the same artist or on the same album or anything) but then when it gets to Z, the next fifty songs are shown organized in alphabetical order starting with A again.  So it looks kind of like this on my iPod songs list:  (using foods instead of songs)
    Apple
    Banana
    Carrot
    Donut
    Eggplant
    Fruit salad
    Granola
    Hot dog
    Ice cream
    Jerky
    Lemon
    Meatloaf
    Nutella
    Orange
    Pear
    Raisin
    S'mores
    Vegemite
    Watermelon
    Yogurt
    Angel food cake
    Bread
    Coconut
    Gravy
    Lime
    Oatmeal
    Peach
    Red velvet cake
    Sausage
    Turkey
    Vegetables
    Avocado
    Bacon
    etc.
    It's gotten very annoying, because it's incredibly difficult to find songs with no known organization.  I tried looking through the "Settings" menu but there was nothing I could find that would help me take care of this. 

    I got it to reorganize alphabetically by resetting the iPod, but then when I synced it again, it went back to the way it was before, and resetting it didn't work.  I tried resetting it while it was still plugged into the computer and that worked.  So for now, the problem is solved.  I'm just gonna post this so that if anyone else needs the solution to this, they can find this somewhat unreliable one, because I've been looking at other questions on this site and apparently nobody that asked a question about this has ever found a solution, so... yeah.  If anyone knows a more permanent solution to this problem, though, please, please please let me know!! 

  • Displaying category portlets in alphabetic order

    Hi Folks,
    When I publish a Category Portlet all items inside this portlet appear in a randomic order.
    I wish they could appear in alphabetic order.
    Is that possible ? How can I do it ?
    Thanks!

    The items in a category portlet are sorted by the folder and the region id within the folder.
    It is not possible to provide a sort order for the items currently, however in 9.0.2, this portlet will be replaced by a customizable search portlet, which allows different sorting options.

  • Page Display - Get rid of alphabetical order???

    Is there any way to organize your pages the way you want within a page group? The reason for my question is that when I build a menu using the DHTML menu builder provided by Ronaldo Viscuso, it grabs the pages straight from the page group, which is always going to be alphabetical. For my purposes, I'd like to order pages by importance.
    Is there any way to do this??
    Any help would be greatly appreciated!!
    Jenny

    Hi Jenny,
    I haven't looked at the DHTML Portlet, but here's one suggestion....
    The Table wwsbr_sites$ in the PORTAL Schema stores information about the PageGroups. If you can "tweak" the Portlet code, perhaps you can order the names of the Page Groups in your own fashoin :-
    select * from PORTAL.wwsbr_sites$ where CREATOR != 'PORTAL' ORDER BY NAME ASC;
    select * from PORTAL.wwsbr_sites$ where CREATOR != 'PORTAL' ORDER BY NAME DESC;     
    select * from PORTAL.wwsbr_sites$ where CREATOR != 'PORTAL' ORDER BY DBMS_RANDOM.RANDOM; Regards,
    Sandeep

  • Index keywords not getting displayed in alphabetical order

    Greetings to one and all!!1
    Why the keywords defined in my index folder, is not getting
    displayed in alphabetical order..what option am i missing to set??
    can anyone help me to achieve this!!!
    Thankx

    Hi all
    In addition to what Colum offered, if you choose to keep a
    non-binary index (those are my particular preference) you may
    right-click the index and sort the terms. (Inside RoboHelp, not in
    the compiled output)
    Just a thought... Rick

  • Display customer details one by one in alphabetical order in alv report?

    Hi experts,
    my requirement is ,
    I want to display customer name  and city as  top and then for particular customer's details (like invoice no's,due date, vat.cst etc)
    display in alv grid format,and then next customer name and detals .....etc.(customer name alphabetical order) in single page one by one. Using ALV reports is possible ? pls give me the brief code (or idea).pls give me solution.
    My input is to enter customer numbers so that output(customer details ) is displayed one by one in order.
    I tried but i didn't get if possible pls give me SDN link.

    Ram,
    loop at internaltable.
    I guess you can use AT NEW fieldname event to display the customer name and then call REUSE_ALV_GRID_DISPLAY for every customer to display the corresponding details
    Thanks
    Bala Duvvuri

  • Display artists in alphabetical order and albums in chronological order.

    I have my iTunes library set to display artists in alphabetical order and albums in chronological order.  This is the sorting option preferred by every person I've ever spoken to about it.  The touble is nobody I've ever spoken to can tell me how to get my device (4S64, 5.1.1) to follow suit.  iTunes on my phone insists on listing albums alphabetically.  Since I (we) already know all the letters of the alphabet and in which order they occur this kind of sorting is of no benefit.  Somebody please put me (us) out of our misery and reveal whichever secret soft switch must be flipped to make this happen.  Also, if possible, I would rather do the alphabetical "Artist" sorting by last name rather than first but I have not seen an option for that either.
    Thank you in advance.

    There is no secret soft switch for Album by Artist by Year on iOS.
    If you want your artists sorted by last name first then edit the corresponding sort values.
    tt2

  • How to switch from reverse alphabetical order?

    Please forgive a newbie question: when I open a list view of my hard drives in Finder, the names of the folders are listed in reverse alphabetical order, with the Z's on top, and the A's on the bottom. How can I change it so that it displays the A's on top and the Z's on bottom, whenever I open the view? Thanks in advance.

    Click the "Name" bar, so the small triangle faces up again.
    You know you can also sort by Date Modified, etc, just click on the column's topbar.

  • Itunes 10 imports cd tracks in alphabetical order only.  What setting do I change so it imports the same order as the cd?

    itunes 10 imports cd tracks in alphabetical order only.  What setting can I change so that it will import cd tracks in the same order as on the cd?  Any help would be appreciated!  I have this issue on only 1 of my 2 macbook pro computers, so I'm guessing it is a setting issue--but I don't know where to find it.

    The apparent order of a burned CD may depend upon how you have iTunes display it - https://discussions.apple.com/message/17827921

  • Web Page Composer - Ordering Automatic lists in Alphabetical order

    Sorry if this is in the wrong place (newbie here)
    I'm trying to order an 'Automatic list' in Alphabetical order - based on page name/title
    So within WPC I have a folder with 10 or so web pages in them. and the next level up I have a page with the 'Dynamic Content' element.
    Within the 'Additional' field of the 'Dynamic Content' element I am able to 'orderBy=modified' or 'orderBy=created' but cannot seem to do what I would think is straightforward and order alphabetically by either name or title.
    Am I missing something simple and obvious?
    Or should I actually be trying to do this by modifying the XSL Template that controls the presentation?
    Thanks in advance for any help.

    Hi Alessio,
    have a look at at this thread:
    <a href="https://www.sdn.sap.com/irj/sdn/thread?threadID=599765">Link for your error message</a>
    Or maybe it is because your WPC isn't fully configured for anonymous access.
    To configure it for anonymous access, try this:
    1. Configuration in PCD - go to Content Administration -> Portal Content-> Portal Content -> Web Page Composer -> Container iViews -> WPC
    Default Containers. All of the iViews in this location should have the
    "anonymous" authentication scheme. The next location which should be
    checked is Content Administration -> Portal Content -> Portal Content ->Web Page Composer -> iView Templates. Again all of the iViews should
    have the "anonymous" authentication scheme. The same applies to all the
    templates which reside in Content Administration -> Portal Content ->
    Portal Content -> Web Page Composer -> Page Layout Templates. Finally
    check if all the pages which reside in Content Administration -> Portal
    Content -> Portal Content -> Web Page Composer -> Page Layouts have the
    "anonymous" authentication scheme.
    2. Configuration in KM - make sure that all the pages, which should be
    displayed to an anonymous user have in their permissions the Anonymous
    Users Group.
    3. Security zones - if you go to System Administration -> Permissions ->Security Zones -> com.sap.nw.wpc -> wpc -> no_safety and you open the
    permissions of this object, the Anonymous Users group must be added in
    the list.
    If all mentioned objects have their setting as described and you still
    experience problems (e.g. you see a browser dialog window for
    authentication), the reason most probably is, that the KM is not
    configured for anonymous access. A full description of the needed steps
    is provided with note 837898.
    I think the your error message could be solved with the first link.
    But afterwards you need to perform the steps mentioned above.
    Regards,
    Marcus

  • How to sort data from database and display in combobox in required order

    Hi evrybody, it makes me sick i need to get data form database and fill combobox in required order (last item added to database - last firstName) actualy i already did that, but i'm useing DefaultComboBoxModel and all records are sorted in alphabetical order. Thanks very much for any help

    The items in the JComboBox are displayed in the order in which you add them to the combo box. Use an order by clause in your SQL statement.
    Don't [url http://forum.java.sun.com/thread.jsp?forum=54&thread=516608]crosspost.

  • Added songs go in alphabetical order

    Hi everyone,
    When I add playlists, albums, songs from my external hardrive to Itunes it is in the order I want. But then I synch the album to my iphone and my iphone adds the songs in alphabetical order and I cant move the songs around like when in a playlist. And I want the order intended. Does anyone know how I can rectify this?
    Thanks
    Eirin

    ridin gaijin wrote:
    Thank you tt2 but it's not a playlist..
    but you also wrote...
    However, on all my playlists, Pala Tute appears in the middle of the album, in alphabetical order, between My Companera and Raise the Knowledge.
    which is why I brought it up...
    Do all the tracks of this album have track numbers? If not, an alphabetical sort by track name is the "correct" iTunes behaviour. Sorting any view in iTunes as *Album, Album by Artist* or *Album by Year* should put the tracks of an album in sequential track order, ascending or decending depending on whether or not the little black triangle in the column heading is pointing up or down. If this view does not give the correct sequence in iTunes, or the track order is wrong on an iPod, then look for problems of consistency with values, esp. capitisation in the album, album artist, artist, sort album, sort album artist, sort artist fields or the disc X of Y labeling.
    If these are mp3 files check that they only have a single ID3v2.3 tag. iTunes sometimes does funny things with files that have multiple tags (e.g. both v1.x & v2.x tags) - displaying information from one version of the tag, but editing (or perhaps even sorting?) using another.
    tt2

  • How to iterate through a treemap in alphabetical order

    This is with a servlet. I will have a button for next and previous. When next is pressed, I go to the next record in alphabetical order.
    I know how to use a comparator and set it up. I also know how to use an iterator with 'hasNext' function. The problem is that the servlet(or jsp, etc...) will display this to the web. Then a doPost will get called and I have to go to the 'next' or previous record from the last time the form was called.
    I don't care about concurrency yet(let me get this part down first). How do i 'track' where I was last and then go to the next record. Or is there an easier way that a treemap. I don't care about performance.

    I'm assuming you want to sort on keys, not values, since that's what SortedMaps do.
    Let's say you're using elements of class C as the keys in the map. Either have C implement Comparable, or create a Comparator that compares to C instances.
    Whether you go the Comparable or Comparator route, the body of the compare or compareTo method will be almost the same. You'll just compare whatever fields are relevant on this/obj (Comparable) or obj1/obj2 (Comparator).
    The only other difference is it's more important for Comparable's compareTo to be compatible with equals, which means you have to override equals and hashCode. You don't have to do so for Comparator, but it can make some subtle issues a bit cleaner.
    Then you could do something like the following: for (Iterator iter = <something>.iterator(); iter.hasNext();) {
        <SomeClass>sc = iter.next();
        // process this element
    } where <something> can be keySet() or entrySet(). Maybe even values(). I think values() will give the sorted order for a SortedMap, but not 100% sure.Check the docs. <SomeClass> will either be the class or the keys (for keySet()), Map.Entry (for entrySet()) or the class of the values (for values()).
    You might want to check out this tutorial, if you haven't already.
    http://java.sun.com/docs/books/tutorial/collections/

  • Alphabetical ordering of subpages - is it possible?

    Hi
    I have portal v 9.0.4.1.0
    In several pages i have regions wich contains subpages. Is there any way to sort the display of these subpages alphabetical?
    Regards
    Maja R. Anjer

    Hi Maja -
    Go to the Page properties for the page that has the sub-page region on it. On the "Others" tab - if you scroll down, you will see where you can specify what subpages should show - and there is a checkbox to display them alphabetically. If this is not checked they will show in the order you have them arranged in the Page properties.
    Hope this helps,
    Candace

Maybe you are looking for

  • How does one submit a complaint to Apple UK about a serious lack of customer support?

    HI, The problem I'm having is finding an addess (e-mail, postal or phone) to complain to Apple about the abysmal customer experience I've had with them. I've been a loyal customer to Apple; having spent in excess of £10,000 over the past 10 years on

  • OSB 11g - Issue with namespace prefix

    Hi, I have a requirement that , whenever I call my target system through business service, always the prefix for a namespace should be 's'. I added namespace as - s : http://www.starstandards.org/STAR When I create request message before calling the

  • Comparing all the values in an array list

    So basically I have an arrayList of numbers that I want to compare against each other so that I can return the value with the highest number. For example if I had an arrayList with the values 3, 4, 6, and 5 I would want it to return 6. I've been fool

  • Scan Via FTP

    Hi I have a Printer/copier that can scan via ftp. No software was supplied to scan via ftp for Mac. However I can scan to FTP in Windows. Any ideas? Thank in advance

  • Problems Using Office 365

    Hi, I have been using office 365 small business premium product. Since last 3 days I am facing problems with all the Office products. I was using Microsoft Word, and I was prompted to install "Proofing Tool" which I installed. After that Outlook is g