Sorting array double or int value and keeping the associated identifier.

Hi,
How would I sort an array which contains a double or int value (I know how to do that) but I also want to keep the unique identifier which is associated to array element after the array has been sorted:
example:
identifier: 15STH7425042735
double: 742500.000
Thanks,
John J. Mitchell

Please define an it in form of entity first and then think of operating on structured data.
a better approach here would be please create an instances of appropriate structured data arrange them in form of a list and then apply specified logic on them
here is an example which you might think of implementing it and would more appropriate as per your stated requirements.
public class SampleBean implements Serializable{
   private String uniqueIdentifier = new String();
   private double appValue = 0.0;
   public void setUniqueIdentifier(String uniqueIdentifier){
       this.uniqueIdentifier = uniqueIdentifier;
   public String getUniqueIdentifier(){
      return this.uniqueIdentifier;
   public void setAppValue(double appValue){
          this.appValue = appValue;
   public double getAppValue(){
        return this.appValue;
}Sample Comparators:
Comparator comparator4AppValue = new Comparator(){
      public int compare(Object obj1,Object obj2){
              return Double.compare(((SampleBean)obj1).getAppValue(),((SampleBean)obj2).getAppValue());
Comparator comparator4UniqueIdentifier = new Comparator(){
      public int compare(Object obj1,Object obj2){
              return ((SampleBean)obj1).getUniqueIdentifier().compareTo( ((SampleBean)obj2).getUniqueIdentifier());
};Assuming that you have acquired an Array or List 'N' Elements of SampleBean with appropriate values.
the belows is the method of how to sort specified Array/List
In case of array
SampleBean sb[] = this.getSampleBeansArray();
// in order to sort using double value inside SampleBean array.
Arrays.sort(sb,comparator4AppValue);
// in order to sort using unique Identifier value inside SampleBean array.
Arrays.sort(sb,comparator4UniqueIdentifier);In case of a list
List sb = this.getSampleBeansList();
// in order to sort using double value inside SampleBean array.
Collections.sort(sb,comparator4AppValue);
// in order to sort using unique Identifier value inside SampleBean array.
Collections.sort(sb,comparator4UniqueIdentifier);Hope this might give you some idea of how to go about.:)
REGARDS,
RaHuL

Similar Messages

  • Get every 10 sec a int.value and need to take the sum of the last 18 values

    Hi,
    i get every 10 sec a int.value and need to take the sum of the last 18 values (3 minutes).
    the programm should work permanently.
    I tried with a 1d-array but didn´t get a result. Could anyone help me?
    Best regards
    kasche

    Use the example in the posted link, then add another shift register for your sum of all elements. Dont add all the elements every time, add them to a running total when they come in. You will need to evaluate how big this number is going to get, however, and decide if you should use an I64 for your running total of all elements. Even this will overflow eventually. 
    So your code would look like that posted by GerdW in the above link, then add a shift register with a starting value of 0. Then add your input value to the value comming from this shift register and send the output to the shift register's output terminal. This creates your running total of all values. The code by GerdW provides your "last 18 elements" total in a very efficient manner, just change the 15 to an 18.
    I have attached a sample bit of code to make it clear. I saved it in LV 8.0 so more people can open it.
    CyberTazer
    Software Systems Engineer
    Attachments:
    Running 18 total.vi ‏11 KB

  • How do I replace quotation marks with double angle quotation marks, still keeping the word in the mi

    Hi,
    Does anyone know how to replace quotation marks with double angle quotation marks, still keeping the word in the middle?
    For example: I search for a word with quotation marks by typing in: (")(\w+)(") in the "find what" field. What should I type in the "change to" field?
    I'd be very grateful for answers!

    It's much simpler: find " and replace with " (make sure that 'Use typographer's quotes' is enabled in the preferences).
    Peter

  • How can I take a screen shot on the iPad Air and keep the resolution at 2048 x 1536. For some reason when I'm in an app it reduces the resolution

    How can I take a screen shot on the iPad Air and keep the resolution at 2048 x 1536. For some reason when I'm in an app it reduces the resolution

    Tatanka11 wrote:
    I'm new to Mac,...
    Then...  You may find these Links of Interest and Value...
    Show me how to set up my Mac.
    http://www.apple.com/support/mac101/
    http://www.apple.com/support/switch101/     Switching from PC
    http://www.apple.com/findouthow/mac/
    Enjoy your Mac...

  • HT201365 how do I now close apps the old way of double clicking Siri button and touching the app no longer works

    how do I now close apps the old way of double clicking Siri button and touching the app no longer works

    There isn't currently a way to edit or control which apps appear in the 'open in' list apart from deleting (or deleting and reinstalling) apps - you could try leaving feedback and maybe in the future we'll have some sort of control : http://www.apple.com/feedback/ipad.html

  • How can I delete the video and keep the Audio  in a few frames using Imovie 11

    How can I delete the video and keep the Audio  in a few frames using Imovie 11?

    I've met the problem too before. but i solved it with  Audio Converter Mac instead of iMovie. If you have similar situation that just want to keep audio but not video, and if your file format is not workable in iMovie, you can use the Audio Converter for help too. it can easily help to extract audio soundtrack from any video format. Or if you need to convert one audio format to another, it is a good choice too, because it supports many common audio output formats.
    <Link Edited By Host>

  • I need to move 1000 photos from one library to another. How do I do that and keep the ratings and dates they were created?

    I need to move 1000 photos from one library to another. How do I do that and keep the ratings and dates they were created? I tried exporting them, but it loses all info. Also, how do I move the quicktime movies from one iphoto library to another? They were exported as jpgs

    Add both libraries to iPhoto Library Manager.  Then select the events or albums that you want to copy from library A  and drag them to library B in iPLM.
    This video shows the process:
    OT

  • Ok, so I transferred my 3S info to my 4S by restoring from an old phone backup.  But SIRI is gone and god knows what else??  Can I get my old stuff into the new phone and keep the 4S new functionality?

    ok, so I transferred my 3S info to my 4S by restoring from an old phone backup.  But SIRI is gone and god knows what else??  Can I get my old stuff into the new phone and keep the 4S new functionality?

    I suspect unless he had some items in iCloud backup then they are gone.  Connecting an iPhone to a different library from that to which it was previously connected will result in the device asking if you want to erase it.

  • Is it possible for automator to convert all word documents in my dropbox folder to apple's "pages" on iCloud and keep the same folder organization?

    Is it possible for automator to convert all word documents in my dropbox folder to apple's "pages" on iCloud and keep the same folder organization?  I am a teacher and want to switch from using microsoft office on my macbook pro to using pages/number/keynote.  I am hoping to get an iPad next year and go "paperless" with lesson plans and gradebooks and I heard that pages/numbers/keynote are great on the ipad.  I'd like to write an automator script (workflow?) to convert all my documents in dropbox to pages and have them stored on iCloud, then be able to access the files on my macbook pro and ipad.  Thanks!

    Create an AppleID under different email addresses for each family member at http://appleid.apple.com
    If they don't already have their own email address just setup a free one with Gmail, Yahoo, Hotmail or whoever you prefer.
    Then on each device sign into iMessage with the users own AppleID in:
    Settings > Messages > Send &amp; Receive > Tap AppleID at top > Sign Out, then sign back in again with the correct AppleID.

  • How do I select a black and white sketch from a white background and keep the filled in area of the sketch?  I want to copy it to a colored background. I amusing elements 12.

    How do I select a black and white sketch from a white background and keep the filled in area of the sketch?  I want to copy it to a colored background. I am using elements 12.

    oesrowstreasurer
    Please clarify your "Elements 12". Is that as in Photoshop Elements 12 (photo editor) or Premiere Elements 12 (video editor). And, on what computer operating system is the program running?
    Your question is pointing to Photoshop Elements 12 and that you have posted in the wrong forum. If this is a Photoshop Elements 12 question as I believe it is, please post your thread in the Adobe Premiere Elements Forum using the following link provided for your convenience
    https://forums.adobe.com/community/photoshop_elements
    The alternative is to wait for a moderator to see your thread here and move it from here to the Adobe Photoshop Elements Forum..
    We will be watching for a confirmation on what program you are using.
    ATR

  • I just received a new ipad and presently have an ipad 1. I was wondering how i can transfer everything from my old one to my new one and keep the same accounts and passwords or is it even possible or do you have to repurchase all of your apps

    I have an ipad 1 and just receive the new one.  I was wondering how i can transfer the apps and things that i have on my old one to my new one and keep the same account names and passwords.  Or do I have to purchase averything over again.

    How to Transfer Everything from an Old iPad to New iPad
    http://osxdaily.com/2012/03/16/transfer-old-ipad-to-new-ipad/
     Cheers, Tom

  • This field contains duplicate values. Remove all duplicate values and try the operation again.

    Greetings Everyone,
    I am getting the follow up errors: "This field contains duplicate values. Remove all duplicate values and try the operation again."
    when I tried to make the field "Claim Number" from the list in site collection library. See the screen below:
    1- I selected on the "List" and I clicked on the list name
    "Claim Tracking Report"
    2- After I clicked on the list name then I went to the ribbon and selected list setting to choose Enforce Unique for the Field Column
    "Claim Number"
    3- Then I went down and selected
    "Yes" to Enforced the Unique for the Field Column "Claim Number".
    4- Then after I clicked "Yes" I got the error
    "Sorry, something went wrong. This field contains duplicate values. Remove all duplicate values and try the operation again."  But I don't have any duplicates values Items, because I had them removed before I tried
    to Enforce the field column values to Unique. Can someone help or provide me a suggestions on how I can solve this issue please. Thank you
    FYI: I am using a Nintex Workflow

    Hope this is a list, how many total items are there?
    Please try to open this list as access(link in IE) and run this query in access
    SELECT Claim.[Claim Number], Count(*) AS Expr1
    FROM Claim
    GROUP BY Claim.[Claim Number]
    HAVING (((Count(*))>1));
    Hope it will show something! if this does not show you dups then better to create a separate list and migrate items after configuring unique column.
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • HT4623 I tried updating to iOS6 via itunes bc my storage space was pass limit and now my phone is telling me it's in recovery mode and I need to restore it. I didn't back it up. How do I take it out of recovery mode and keep the information on my phone?

    I tried updating to iOS6 via itunes bc my storage space was pass limit and now my phone is telling me it's in recovery mode and I need to restore it. I didn't back it up. How do I take it out of recovery mode and keep the information on my phone?

    You cannot.  If it is in recovery mode, the data is already gone.
    Did you fail to make sure everything was on your computer before updating?

  • I want to burn a DVD and keep the pictures in the files

    I am using iPhoto 8.  I have 46 albums that I created for one vacation.  I have organized all of the pictures from 5 cameras and want to burn a DVD keeping the pictures in those albums so others can create a slideshow from them.  When I burned a DVD the files did not show up, so all of the work was for nothing.  How can I burn the DVD and keep the files intact so other people do not need to do the same work that I have already completed?

    As Terence mentioned for those with Macs and iPhoto select the albums you've created and use the Share ➙ Burn menu option.  This will create a mini library on the disk that others can view in iPhoto and run slideshows from the photos in the album or copy those albums into their library for more control.
    Click to view full size
    OT

  • How to retrieve the procedure value and pass the value to a form field

    How to retrieve the procedure value and pass the value to a form field?

    Set property for the field and the value is the actual procedure/function.
    Cheers

Maybe you are looking for

  • I need to move my itunes library from a pc to a laptop in a different home, can I do this? help!

    I had set up my original itunes library on a pc in my previous home.  I have left this home due to a marriage split up and now live somewhere else. I have a new  lap top which I am desperate to update my ipod nano on. I have set up home sharing, and

  • Existing Calendar Entries not Syncing to iCloud

    I have an iPhone 5 running iOS 7 that has five calendars.  I attempted to sync it to my iCloud account today and it only syncs one of my calendars ("Work").  The other calendars ("School", "Home" etc), show up in iCloud in the Calendars sidebar, but

  • Keynote compatibility w/Powerpoint

    My daughter is supposed to do a Powerpoint presentation for her A&P class and burn it to a cd. If she does her presentation on Keynote for Mac will her prof be able to access it through his Powerpoint?

  • OS Authentication via JDBC

    Can someone provide a code example of How to Connect With Operating System Authentication Using JDBC/OCI? Thanks

  • Can single interface accomodates multiple bridge groups

    Hi,    I am working on building FW configuration to serve multiple tier environment. The FW is in Transparent Mode, Sw Ver 8.4 which supports Bridge-group. My question is, whether FW supports having mutilple Bridge-groups under single interface. If n