Sorting a combination of two longs using a comparator

Hello to all,
I need to implement a comparator that will take as input an object containing two longs, combine them and sort them in the form a.b, where a is the first long and b the second, first by a and then by b. (eg.1.2, 2.8, 1.5, 2.4, 3.4, 3.3, etc... becomes 1.2, 1.5, 2.4, 2.8, 3.3, 3.4, etc..)
Is there a way to achieve this?
Thank you in advance!

like this?
class LongComparator implements Comparator {
  String delimiter;
  public LongComparator(String delimiter) {
    this.delimiter = delimiter;
  public int compare(Object o1, Object o2) {
    String[] s1 = ((String) o1).split(delimiter);
    String[] s2 = ((String) o2).split(delimiter);
    Long l1s1 = Long.valueOf(s1[0]);
    Long l2s1 = Long.valueOf(s1[1]);
    Long l1s2 = Long.valueOf(s2[0]);
    Long l2s2 = Long.valueOf(s2[1]);
    if (l1s1.compareTo(l1s2) == 0) {
      return l2s1.compareTo(l2s2);
    } else {
      return l1s1.compareTo(l1s2);
}

Similar Messages

  • We have a large family, 5 kids and two adults all with iPads, iPhones, Mac Books, Servers....  How can we combine our purchases to use on all our devices.  We have two Apple ID's and sometimes buy multiple copies because of how we are limited...

    We have a large family, 5 kids and two adults all with iPads, iPhones, Mac Books, Servers....  How can we combine our purchases to use on all our devices.  We have two Apple ID's and sometimes buy multiple copies because of how we are limited...

    Hello Halfback71,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    Frequently asked questions about Apple ID
    http://support.apple.com/kb/ht5622
    I have multiple Apple IDs. Is there a way for me to merge them into a single Apple ID?
    Apple IDs cannot be merged. You should use your preferred Apple ID from now on, but you can still access your purchased items such as music, movies, or software using your other Apple IDs.
    If you are wondering how using multiple Apple IDs relate to iCloud, see Apple IDs and iCloud.
    Best of luck,
    Mario

  • I have purchased an Iphone 4 in Dubai two years ago. The model number is MC319LL. And unfortunately, I attempted to upgrade it online to a newer version 5.0.1(9A405) but right away my sim card was blocked. I can no longer use the telephone.

    Dear Sir:
    Two years ago I have purchased an Iphone 4 here in Carrefour Supermarket, Dubai UAE. The model number is MC319LL. Unfortunately last November 2011, I attempted to upgrade the OS to 5.0.1 but rightaway, my sim card(Etisalat UAE service provider) was blocked. As a result, I can no longer use the telephone function. I just found out recently that this model number .i.e.MC319LL is to be used for AT&T. My question is, how can I restore my unit to work as a celphone? And why is it that when I upgraded it, it was blocked. Was it illegal to sell this phone in the UAE market?
    Thanks a lot.
    Kathleen Jewel

    You purchased a "hacked" iPhone(hacked to unlock it) from a non-official source for iPhones. Unfortunately, that's the risk you take when you purchase from a non-official source. There is no way to get your phone officially unlocked, & all warranty & support has been voided. Sorry, but you don't have any good choices here. Your best bet is to go back to Carrefour Supermarket & get your money back, then purchase an iPhone from an official source. If they won't give you your money back, have them "fix" your phone...they will have to "hack" it again. Good luck.

  • I have two email accts. set in my iphone,one is the default setting.when I send an email it shows that it was sent from a 3rd email acct. that I no longer use?I deleted it from my phone?

    I have two email accts. set in my iphone,one is the default setting.when I send an email it shows that it was sent from a 3rd email acct. that I no longer use,and had been deleted  from my phone?

    Install ClamXav and run a scan with that. It should pick up any trojans.   
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • Can no longer use the Remote app on iPhone 5 or iPad 1

    Hi,
    I've long used the Remote app to control my iTunes library which I stream through two Airport Expresses. It's been a great solution for some time.
    However, since the latest updates, I can no longer do this. The iTunes library does not show up in the app, only a message telling me to turn on Home Sharing in iTunes.
    I have turned Sharing off and on on the iPhone, iPad and iTunes but have had no luck getting it to work.
    Any suggestions welcome!
    Thanks
    Phil

    Thanks Linc,
    well that *****... I guess I am going to have to reach out to the developers. It does not look like they are doing this anytime soon cause the website is pretty old in itself.
    Thanks for the info on this,
    Paul

  • I changed my AppleID a long time ago to an email that I no longer use and I have updates for apps that I can't update because my old email is filled in to where i sign in and it wont let me change it to my new one???

    I changed my AppleID a long time ago to an email that I no longer use and I have updates for apps that I can't update because my old email is filled in to where i sign in and it wont let me change it to my new one???

    The problem with those two apps is that they are supposed to be in your Apple ID and you didn't set up the Mac properly/completely when you got it.
    You might try deleteing them and using OS X Recovery to install them again.
    OS X Recovery -
    http://support.apple.com/kb/HT4718
    After that, before you open any iLife apps go to your Mac App Store account, to the Purchased pane and Accept them into your account.

  • If two people use one computer, but we have separte itunes accounts, Apple ID, and icloud will my apps I get be stored in their account too since we are using the same computer?

    If two people share the same computer, but have separate itunes account, Apple ID, and icloud and one of them downloads an app will it also go into the other persons account since y'all use the same computer

    If you  have separate user accounts on the computer, then your downloaded apps are stored in your iTunes Library. See the following for dealing with having multiple users on the same computer: How to use multiple iPhone, iPad, or iPod devices with one computer.
    Using More than One iDevice on the Same Computer
    This applies mainly to couples who are adding another device and do not want their email, messages, etc. being duplicated on both devices. To begin read: How to use multiple iPhone, iPad, or iPod devices with one computer. You need to establish a separate Apple ID and password for whomever will use the new iDevice. See Apple - My Apple ID and Frequently asked questions about Apple ID. The easiest way is to do this on the computer using iTunes: iTunes- How to set up an Apple ID within iTunes.
    On the computer create a new user account for the person with the new iDevice. This will be the user account that person will always use. He/She will no longer use the other user account. This way that person will have a separate iTunes Library
    Start by transferring the new device(s) to a new account along with all your data.  Save any photo stream photos that you want to keep to your camera roll (unless they are already in the camera roll) by opening your Photos app, tap on Albums icon at the bottom. Now, tap on My Photo Stream album; tap Select; tap on the photos you want to select;, tap the share icon (box with upward facing arrow) in the lower left corner; then tap Save to Camera Roll.
    If you are syncing notes with iCloud that you want to keep then you need to open each of your notes and email them to yourself. Later you can copy and paste the text into new notes created in your new account.
    Tap on Settings > iCloud > Delete Account (only deletes it from this device, not from iCloud; the person keeping the current account will not be affected,) provide the password to turn off Find My Phone and choose Keep on My iDevice when prompted.  Sign in with a different Apple ID to create your new account. Choose Merge to upload your data.
    Once you are on separate accounts, you can each go to icloud.com and delete the other person's data from your account.
    Note: The essence of the above was created by user, randers4. I
    have made substantial changes to improve readability and syntax.

  • HT5312 how can I change my iCloud account ID it has an email address that i no longer use.

    Hi I have an iCloud accout under a ID that I no longer use. How can I change it to use my new ID

    Hello Rodney
    Welcome to the Apple Support Communities. If you want to switch the Apple ID, the following article will sort you out.
    Apple ID: Changing the email address you use for your Apple ID
    http://support.apple.com/kb/HT5621
    Regards,
    -Norm G.

  • HT3819 If my partner & I both have an iTunes account, can we home share both or somehow combine the two accounts?

    If my partner & I both have an iTunes account, can we home share both or somehow combine the two accounts?

    As of right now there is no way to combine Apple accounts.
    As for "sharing", you can go into the iTunes settings for each and turn on Home Sharing, this will make your music libraries available to each other, provided you are both using different computers.

  • In Bookmarks, when I right click on a bookmark "SORT BY NAME" is no longer there. how do I get it back?

    In Bookmarks I used to be able to right click on a bookmark and in a menu box I could click on, SORT BY NAME, sort by name is no longer in the right click menu. I don't want to have to drag to sort bookmarks as I have too many. How do I get "SORT BY NAME" back in the right click menu in Bookmarks? Thanks, HT

    In Firefox the option to sort bookmarks is only available for folders and not for individual bookmarks.
    Easiest to sort by name is to do that in the left pane of the Bookmarks Manager (Bookmarks > Show All Bookmarks) and right-click the folder that you want to sort.
    *https://support.mozilla.org/kb/Sorting+bookmarks

  • Months of frustration - can no longer use my Droid Razr M for calls at home

    I'm hoping that a Verizon customer support person will see this and contact me. As detailed below, because of cell reception issues in my neighborhood and especially at my house, I can no longer use my phone to make or receive calls in this area. I have been patient while working with customer support for several months, but my patience is at an end. If I can't get an immediate fix for this problem, then I request that the early termination fee waived.
    I've attempted to work with Verizon customer support for the last many months regarding poor cell reception in my area of Durham, especially at home. I get excellent reception elsewhere. During calls, people frequently have problems hearing me (I'm tired of having to repeat myself so often) and calls are frequently dropped. There have been a few instances when a single conversation will be conducted over three or four separate calls because of drops. Walking around my house -- even trying to walk outside in hopes of getting a better signal -- makes the problem worse.
    Here's the kicker: I've found a temporary solution in using a $10 Tracfone that gives me great reception. I've relied upon it for most calls at home over the last 6 weeks or so.
    Since October, following different phone or web conversations with Verizon support and visits to local Verizon stores , I've had the Preferred Network Mode reset to LTE then later reset back to Global (neither change made a difference)  I've replaced the SIM card (made no difference), I've rec'd a replacement phone (no difference). During the visit to the Verizon store about a half mile from my house to get a new SIM card, one of the sales associates warned that I wouldn't be able to determine right away whether it made a difference since reception in the neighborhood was so bad.
    I most recently contacted customer support on Feb 8, I spoke with someone who reviewed the record of my calls and could see several drops. He encouraged me to use my Razr at home more often so that Verizon could have as much data as possible to troubleshoot the issue and asked that I call back in a week or two. .
    So I've been using the Razr more often but to great frustration. I've had business calls drop several times back on Feb 12 & 13, and multiple drops again on Feb 25. Other calls did not drop but people would often interrupt me to say that I was breaking up or fading out, so I'd have to move around my house or go outside or come back inside until they could hear me more clearly again.
    What makes this worse is I've had no luck getting back in touch with customer service the several times I've tried over the last 4 or 5 days. I've tried calling several times but end up hanging up after being on hold for several minutes and I've tried the Live Chat but always get the "all agents are busy" message. Have tried mornings mid day, evenings, but it makes no difference.
    So if I can't get an immediate fix for this problem, I would request that the early termination fee (I'm just shy of 13 months into a 2-year contract) be waived in light of the frustrations and the long period over which I've tried to work with Verizon to find a solution but without success.

    I'm adding screen shots taken from this afternoon showing connection that varied from non-existent to 1X.

  • HT3819 Since the last AppleTV update I can no longer use home sharing. chI have checked all IDs, rebooted iTunes, AppleTV, and my router, eck port settings in my firewall. Nothing works. Is it me or did this update screw things up?

    Since the last AppleTV update I can no longer use home sharing. I have checked all IDs, re-booted iTunes, my router, and AppleTV, and checked the port settings in my firewall. nothing works. Is it me or did this last update really scew things up?

    Hi,
    I tried everythink, but same as before!
    - droppings ot the main screen
    - loosing Home Share
    now even on iPads !
    Frustrating!
    I'm now more than convinced that this is caused by the latest iTunes version.
    As some others stated in other threads .... it seems that Apple doesn't really take care of this problem. So what if, if we could make them feeling the same pain as we do. ... Just by dropping them a mail as soon as we have the problem again. Not more often, we don't want to be unfair, but everytime it happens.
    I found this feedback site http://www.apple.com/feedback/itunesapp.html
    I will start now with this.... maybe this will help to rise a little bit of attention
    Tweety
    This is the mailbody I always use
    Hello all,
    Since the last update to iTunes Version 10.6.1 (7) streaming content (Movies and TV shows) to Apple TVs and iPads has two major problems:
    - Home Sharing is lost during streaming (streaming stops even if a large portion of the content is already preloaded)
    - streaming stops and the main screen pops up (Home Sharing still available)
    This happens sometime after some minutes, sometimes after several hours, but it surely happens.
    I followed every advice I could found on this support website. There are now a lot of threads following this issue.
    Sometimes it seems getting better, but hours later the same isues occured again. Watching content on this enviroment is a real pain and very frustrating.
    As many others I'm now convinced that the latest update of iTunes caused this problem.
    Our family enviroment contains the following Apple products:
    - iTunes on a Win7 32 bit Noname PC (all content)
    - second iTunes on a iMac with OS 10.6.8 (all content)
    - third iTunes on a MacBook Pro with OS 10.6.8 (daughter, only selected content)
    - fourth iTunes on a Win7 32 Samsung Notebook (son, only selected content)
    - all iTunes sharing the same Home Sharing ID
    - 2 Apple TV second generation
    - 1 Apple TV first generation
    - 2 iPod touch (bought last year)
    - 2 iPads (second generation)
    all firmware or software are on latest available patchlevel.
    At this moment, I can not recomend to others to buy this products.
    I will drop this feedback everytime my famiily and I facing this problem... just to help you to get a better feeling of the urgency of this issue.
    Thanks for every effort in advanced.

  • Why can I no longer use an image for my signature on forms?  The only option I have now is "use a certificate".  It was never like this until today.

    Why can I no longer use an image for my signature on forms?  The only option I have now is "use a certificate".  It was never like this until today.

    Hi,
    I had never heard of someone using the iPhone Number as the ID in the iMessages account in the Mac version.
    i.e without adding an Apple ID
    iMessages does allow iPhone numbers and mine lists mine.
    I would try this.
    Sign Out of the iMessages account and Quit Messages
    On the iPhone in Settings > Messages remove the Apple ID
    Set the iPhone to Airplane mode for a few minutes (to break with the  Server)
    On starting the phone up again check the iPhone Number  is ticked for iMessages.
    If it is add the Apple ID
    On the Mac restart Messages
    Add the Apple ID
    At this point you should get a pop up or two saying the iPhone is using the Number and Apple ID.
    Accept these and they get added to the Receive At list and Send From drop down.
    9:41 pm      Monday; October 28, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Problem with combination of two working query formulas

    Hey guys,
    I have a problem in building a formula correctly with the BEx formula logic. I am sure, you can help me with this.
    Right now I have four columns in my query. The first column (Actual) displays actual amounts either in local (10) or reporting (25) currency type depending on the optional selection either in the variable screen or in the free characteristics filter. The second column (Actual with Budget exch. rate) always shows the actual amounts with the budget exchange rate of the reporting currency. The third column (Budget) is build in the same way as the first column, but shows budget amount data. In the fourth column (Variance) the variance between budget and actual data should be calculated, but here lies the problem:
    The formula should differentiate the chosen columns for the calculation depending on what currency type is selected either from the optional variable selection before the query is executed or from the free characteristics filter. So if I select currency type 10 it should calculate the variance by subtracting the budget column from the first column, but if I select currency type 25 it should subtract the budget columng from the second column.
    I have implemented a formula which works already, but not for both selection possibilities (variable screen or free characteristics filter). Either the formula works when I input a currency type in the variable selection screen or when I select a filter value in the free characteristics filter. However, I need to combine both formulas in one working formula so that the user can choose if he wants to filter the currency already in the variable screen in the beginning or in the filter after query execution. Here are the two formulas which I need to get combined into one formula:
    Used Variables:
    VScreen_Selection --> value from the key of the optional Currency Type Variable from the Variable Selection Screen
    Filter_Selection: --> value from the key of the InfoObject Currency Type
    Formula for Variable Screen Selection:
    (VScreen_Selection == 10) * (Budget - Actual) + (VScreen_Selection == 25) * (Budget - Actual with Budget exch. rate)
    Formula for Free Characteristics Filter Selection:
    (Filter_Selection == 10) * (Budget - Actual) + (Filter_Selection == 25) * (Budget - Actual with Budget exch. rate)
    Can you help me to combine both Formulas? I can't believe that this is too difficult. Many Thanks in advance.
    Best Greets,
    Norbert

    Hello.
    Did you try this:
    Formula 1: Hidden
    (VScreen_Selection == 10) * (Budget - Actual) + (VScreen_Selection == 25) * (Budget - Actual with Budget exch. rate)
    Formula 2: Hidden
    (Filter_Selection == 10) * (Budget - Actual) + (Filter_Selection == 25) * (Budget - Actual with Budget exch. rate)
    Formula 3:
    (Filter_Selection <> 10) * (Filter_Selection <> 25) *Formula 1 +
    (VScreen_Selection <> 10) * (VScreen_Selection <> 25)*Formula 2

  • Combined FIles in PI using BPM without correlation

    Hi All
    I have a requirement, I have two files coming from the source system one file with Header Detials & other file with Item Detials and I have to combine these two files into a single file.
    I have used the BPM in PI to combine the two files uisng correlation.
    This scenario is working fine if both the files are having equal number of records wiht the same correlation ID.
    Based on the correlation ID files will be combined in PI and send to the target system.
    Now in case I am receiving the files in which corelation is not matching for few records then in that case process in waiting in BPM and get cancelled after some time & files will not be processed.
    Do we have any option in BPM which will just cominge two files without correlation & passed through BPM & files got processed?
    Thanks for your help in advance.
    Thanks
    Ajay

    Hello Ajay,
    I do agree with Anudeep that corelation is necessary to in order to merge the two messages.
    I am sure you will find a correct corelation factor in order to merge the messages.
    If there is no corelation, you can ask the functional consulatant to add certain veriables in the incoming messages that will corelate the messages.
    Tx
    Saurabh

Maybe you are looking for