In plain english please...

Can anybody explain to me the logic behind this sort algorithm using a comparator?
I don't understand the usage of "o1" and "o2", and I also don't understand why 1, -1, and 0 are returned and what is done with those values if they are returned.
Thanks.
java.util.Arrays.sort(names, new java.util.Comparator<String[]>() {
public int compare(String[] o1, String[] o2) {
if(Integer.parseInt(o1[1]) > Integer.parseInt(o2[1])) {
return 1;
} else if(Integer.parseInt(o1[1]) < Integer.parseInt(o2[1])) {
return -1;
} else {
return 0;
}

One question though, if I wanted to compare and sort
more than 2 items in a column in my 2d array, would I
have to compare o0 to o1, o1 to o2, o2 to o3, and so
on?If you're writing compare/compareTo, no. If you're writing sort method, yes.
Your compareTo method (Comparable) or compare method (Comparator) is only responsible for comparing two things. The sort routine--Collections.sort or Arrays.sort--is responsible for ivoking your compare method on the various pairs of items in order to get the list or array sorted.
The meat of the work of sorting is done by the sort method. It has the logic, "if A < B then swap A and B," etc. all you're doing in compare/compareTo is answering the sort method's question "Is A < B?"
These may be the same online tutorials that you found cryptic, but look at these and see if they help.
Making Java Objects Comparable
http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

Similar Messages

  • Newbie question: how do you reset the router; in plain English please

    I need some help in plain English please.  The router stopped working and maybe just needs a reset.  I tried reading http://www.cisco.com/c/en/us/support/docs/ios-nx-os-software/ios-software-releases-123-mainline/46509-factory-default.html, but I don't understand the first thing.  It's a Linksys E2500.  Is this even the right forum?

    You are reading a Nexus IOS guide. Nexus is a carrier grade switch so don't mind that. Try this instead.
    http://kb.linksys.com/Linksys/ukp.aspx?vw=1&docid=eaa3127db5f4402584c959a7251e754c_4008.xml&pid=96&slnid=2

  • What is Silverlight? In Plain English, Please.

    Referring to: http://go.microsoft.com/?linkid=7472851 
    Do you know what I wish?  I wish, just for once that a simple and concise description of what a product is and what it really can do could be posted right up front, on the landing page, or at most one link deep.  Not the marketing hype, not the techno-speak,
    not the jargon.  Just a plain simple description of what the thing does, what it is.  That would be really nice. Because, all I see on the pages I have visited from the link above is just that, techno-speak, jargon and hype.
    Look.  I get lots of e-mails, every day.  So, I get one from Microsoft indicating this new product, Silverlight, is available.  It sounds interesting, The graphics sure are nifty.  So, I click on the link to see if it is something I am interested in. 
    I mean, "Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web." is a nifty one-liner.  But, it really does not say much.  It means nothing to most
    people.  (Not everyone who receives MS e-mails is a top-level multi-certified techno-geek!)
    There ought to be a link titled something like "What is Silverlight."  This link would lead to plain-English description of the product.  Again, cut the techno-speak.  Provide a concise description of the product, what it can do, how it does it and stuff like
    that.  Let me decide if it really is as fantastic as the marketing department wants me to think it is.  Look, I'll give you 5 or maybe 10 minutes of my time to read through your descriptions, and then I will decide if it is so great that I want to invest considerable
    time and energy learning how to work it.  And, if there is a cost involved, whether it is something I want to shell out the going rate for.
    How about it?  Think about it.  Can someone have the balls to just cut the techno-speak, jargon and marketing hype and give it to us in plain English?  Please.

     Thanks for your response.  Okay, so it's a platform, not a "product."  Semantics.  Do you understand my point?  Too often it seems that product/platform descriptions are written with so much jargon and techno-speak that unless one is fluent in the jargon
    it is difficult if not impossible to quickly understand what a new product is.  (Product being a generic term here to point at the new thing.)  You see, in your reply you have begun to describe it in terms more easily understood.  That is precisely
    my point.  Too often when companies, MS and others, attempt to describe their products they use a barrage of jargon and techno-speak that makes if very difficult to understand in simple terms what the product actually does.  I know, everyone wants to keep
    up with the competition and impress with their command of fancy terms.  But, good effective communication is not about jargon.  It is about describing in clear terms so that people in a busy world full of time constraints and demands for our attention can
    gather information, distill it and make decisions as to what new products to understand, learn and implement.  That is my point.  My point is not a question.  My point is a heads-up to remind folks that it is important to communicate clearly and with precision. 
    Marketing is great, but useless if folks can't get the information they need to understand and make decisions.  We live in a world saturated with information.  Clouding information with jargon and techno-speak may appear impressive but it hinders the effective
    delivery of information.  Also, please don't assume I'm asking for "baby terms."  I'm not.  I can understand what something like Silverlight does.  But too much jargon gets confusing and results in my either spending extra time trying to understand the jargon
    or simply deciding it's not for me and moving on to something else.  Of course, all of us working in the various IT endeavors must use a certain amount of technical terms that are short and understood by those in our various industries.  (I'm no newbie, either. 
    I've been working with and understanding these silicon wonders since the early 1980s.  I also have two college degrees, one in computer science.  So, I'm no idiot.  I'm just not current on every single frigin' term that companies and techno-geeks come up with
    in the ever changing landscape of new terms, processes, products, platforms and other techno-stuff.)  But, even then, we need to be careful that we communicate clearly and effectively.  That is a skill, and art, that, like any skill, requires working at it,
    polishing the skill and efforting it.  So, there's a balance between using jargony terms and overkill.  The art is finding the balance.  Again, it's not a question as much as it is a point to be made.
    MHW22 

  • SE97 and table TCDCOUPLES in plain english please....

    Guys... can anybody please explain to me in plain english what SE97 and table TCDCOUPLES shows me! I read the "called transaction" thing, but can't comprehend the meaning. E.g. if I enter PFCG in SE97 there is a long list of funny transactions.
    Is this a log of transactions called once in PFCG? Or possible transactions called from buttons, ect. from in PFCG? Or is it all the transactions from where you can call PFCG?
    What do I need to do in connection with SU24 and creating roles?
    /vitofava

    Often transactions link to other transactions via drilldown, buttons, views etc.
    Where SAP uses CALL TRANSACTION for this link we can use SE97 to force a check on S_TCODE or to ignore the S_TCODE check.
    An example: MM50 allows the extension of a an material master for other org units.
    As standard MM50 calls MM01 for this and any users with MM50 also require MM01.  It is a common situation where MM50 is required  by users but MM01 is not suitable.  In this case you can use SE97 to set MM01 as "do not check". 
    Users can access MM01 functionality when called through MM50 but do not require MM01 in S_TCODE.  If they try to run MM01 they will get an authorisation as it is not access through/coupled with MM50.
    Like SU24, SE97 isn't completely accurate and a lot of it depends on use etc.  Recently I saw a scenario where particular (legitimate) use of MM02 required S_TCODE for SM30, which on this particular instance wasn't one of the default entries in SE97/TCDCOUPLES
    The parallel with SU24 is that you can switch off some checks on S_TCODE for linked transactions in the same way you can switch off some auth object checks for a transaction in SU24

  • Iris Pro vs. GT 750M in the 21.5" iMac - in Plain English please

    Hey!
    I'm about to go Mac at the office.
    I was gearing up to make the purchase then I see there is yet another choice to make...
    Iris Pro vs. GT 750M
    I've read a bit on forums but it all seems way beyond my techie abilities.
    So in plain english will I notice a difference if I get the cheaper model?
    We mainly work with of Microsoft Office, internet apps and occasional Adobe stuff.
    I've found my Macbook Pro 2012 perfect fast for most of my tasks.
    Thanks!

    Iris pro is basic "good enough to get the job done" hardware to run the display. Its part of the CPU and does very poorly with 3D rendering.
    750M is an actual separate graphics processor with its own dedicated memory and the power to animate 3D graphics at full speed.
    If your Macbook Pro feels "fast enough" for you, the Iris will be "good enough" as well.

  • Junit explained in plain english please.

    I been reading up on JUnit, and i still do not understand it.
    What is the difference? Why not just make an application?
    Please explain it as if you are explaining it to someone who is not very technical.
    Thank you

    What is the difference? Why not just make an application?You could. But it wouldn't be as nice.
    If you have 100 tests, how are you going to organise them in your application? Will you write 100 different applications?
    JUnit allows you to group tests nicely.
    It allows you to share setup/teardown logic to prepare for running your tests.
    It gives you a nice graphical display of how tests went if you're using an IDE (or the command line).
    If you're using a tool like ant, it allows you to stop the script when you encounter a failed test. That's really useful if you're building something based on libraries - you don't want to build the rest of the webapp if one of the libraries it will be made from has a bug in it.
    No, you don't have to use JUnit, but it's much easier to use JUnit than it is not to.
    The simple example you asked for. Here's a real test case that I'm using to check to see if a component for breaking down web URIs is working correctly. Note how I use the nice simple "assertion" methods.
    public class PathHolderTest extends TestCase {
       public void testRootPathAbsolute() {
          final PathHolder ph = new PathHolder("/");
          assertTrue(ph.isFolderPath());
          assertTrue(ph.isAbsolutePath());
          assertEquals(1,ph.getPathElements().length);
          assertEquals("/",ph.getPathElements()[0]);
       public void testSimplePathAbsolute() {
          final PathHolder ph = new PathHolder("/foo");
          assertFalse(ph.isFolderPath());
          assertTrue(ph.isAbsolutePath());
          assertEquals(2,ph.getPathElements().length);
          assertEquals("/",ph.getPathElements()[0]);
          assertEquals("foo",ph.getPathElements()[1]);
       public void testFolderPathAbsolute() {
          final PathHolder ph = new PathHolder("/foo/");
          assertTrue(ph.isFolderPath());
          assertTrue(ph.isAbsolutePath());
          assertEquals(2,ph.getPathElements().length);
          assertEquals("/",ph.getPathElements()[0]);
          assertEquals("foo",ph.getPathElements()[1]);
       public void testSubFilePathAbsolute() {
          final PathHolder ph = new PathHolder("/foo/bar");
          assertFalse(ph.isFolderPath());
          assertTrue(ph.isAbsolutePath());
          assertEquals(3,ph.getPathElements().length);
          assertEquals("/",ph.getPathElements()[0]);
          assertEquals("foo",ph.getPathElements()[1]);
          assertEquals("bar",ph.getPathElements()[2]);
       public void testSubFilePathWithExtensionAbsolute() {
          final PathHolder ph = new PathHolder("/foo/bar/index.html");
          assertFalse(ph.isFolderPath());
          assertTrue(ph.isAbsolutePath());
          assertEquals(4,ph.getPathElements().length);
          assertEquals("/",ph.getPathElements()[0]);
          assertEquals("foo",ph.getPathElements()[1]);
          assertEquals("bar",ph.getPathElements()[2]);
          assertEquals("index.html",ph.getPathElements()[3]);
    }

  • Connector Specific Error. Can anyone PLEASE tell me in plain english not techi talk how to fix this error?

    Connector Specific Error.  
    Can anyone PLEASE tell me in plain english not techi talk how to fix this error?

    Hey royhanif,
    Welcome to the BlackBerry Support Community Forums.
    Thanks for the question.
    Follow the steps in this KB article to resolve the connector specific error: www.blackberry.com/btsc/KB15294
    Let me know if you have any more questions.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • User Profile service in plain english

    Hello Experts,
    could any one please explain in plain English how does User profile services recognize users on SharePoint even if am not configuring the user profile sync service? I mean how SharePoint displaying user display name ? can I get the manager of a logged in
    user without using user profile sync service?
    please do not answer with link. just I need someone to explain it in his words in plain English
    Thanks

    When you log into SharePoint you give it a username and password, this might be automatic so you never notice it but it still happens in the background. The UPS then takes that username and creates a UPS entry for that account using information stored in
    Active Directory.
    If you're not familiar with AD it's normally a generally accessible 'phone book' like collection of user data like username, first name, surname, email address, manager, department and what security groups they belong to.
    If you configure the sync service this information is pulled through earlier in bulk rather than on-demand as users log in. You also get a lot more control over what data is used where and how.
    It's slightly different if you're using Forms Based Authentication but that's another story.

  • Share tab is greyed out when trying to export in FCPX - cannot export - I would like a real answer in plain english! Thank you!

    The share tab is greyed out when trying to export from Final Cut Pro X
    Please help with a REAL answer in plain English.
    Thank you!

    Thank you Tom!
    I checked every clip -
    Trashed preferences too.
    Finally, I took your advice and backed-up  my events and projects.
    Trashed Final Cut Pro X
    Downloaded a new copy from FCPX from the app store (from my previous purchases)
    Restarted FCPX
    Opened my event
    Moved to the timeline - and now!
    The SHARE tab works!
    Every aspect of FCPX is working faster as well.
    Go figure?
    Thanks again!
    Allan - olvblock

  • In plain English - How can I get music from one computer to another?

    Honestly guys, I havent a clue! I have purchased music from my work PC, but cant access it from my Home PC. I have read the manuals, but it dosent make sense to me! So, in ordinary, basic, plain English, how do I access it from home?!

    If you are using iTunes 7 I think this section from the Apple article is pretty straightforward.
    To transfer iTunes Store purchases using iPod:
    Connect your iPod to the computer on which you bought the items you want to transfer.
    Copy the iTunes Store purchases to your iPod.
    Disconnect your iPod (click the Eject button next to its icon) and then connect it to the computer you want to transfer the purchases to.
    Choose File > Transfer Purchases From iPod.
    You could also burn the song files to a data CD or DVD. Once you've burned the disc, take it to your other computer and import the songs into iTunes. Don't forget that regardless of which method you use, both computers have to be authorised to play the songs: About iTunes Music Store Authorisation and Deauthorisation

  • Sorry, Flagfox has encountered a problem. Please copy the report below and post it on our forums with a detailed explanation of what you were doing at the time so we can attempt to fix your issue. (English please) Flagfox version null (missing IPDB!)

    Sorry, Flagfox has encountered a problem. Please copy the report below and post it on our forums with a detailed explanation of what you were doing at the time so we can attempt to fix your issue. (English please)
    Flagfox version null (missing IPDB!)
    ERROR MESSAGE: Fatal Flagfox startup error!
    EXCEPTION THROWN: TypeError: ExtensionManager.getItemForID(id) is null
    STACK TRACE: startup()@file:///C:/Documents%20and%20Settings/Vanessa%20Ecret/Programdata/Mozilla/Firefox/Profiles/9eyewkfc.default/extensions/%7B1018e4d6-728f-4b20-ad56-37578a4de76b%7D/chrome/flagfox/modules/flagfox.jsm:40
    ([object ChromeWindow])@file:///C:/Documents%20and%20Settings/Vanessa%20Ecret/Programdata/Mozilla/Firefox/Profiles/9eyewkfc.default/extensions/%7B1018e4d6-728f-4b20-ad56-37578a4de76b%7D/chrome/flagfox/modules/flagfox.jsm:160
    Flagfox_loadForThisWindow([object Event])@chrome://flagfox/content/overlay.xul:16
    BROWSER: Mozilla Firefox 3.6.6/20100625231939 (Gecko 1.9.2.6/20100625231939) using locale en-US on WINNT x86-msvc
    This error and a Flagfox preferences dump has been sent to Tools -> Error Console. Please report this and any related errors so we can investigate your problem. Conversely, if you don't report this then it probably won't get fixed.
    == i was update

    Sorry, the Flagfox extension has encountered a problem. The following error output and a Flagfox preferences dump has been sent to Tools -> Error Console.
    FLAGFOX VERSION: 4.1.x (missing IPDB!)
    ERROR MESSAGE: Fatal Flagfox startup error!
    EXCEPTION THROWN: TypeError: addon is null
    STACK TRACE:
    (null)@resource://flagfox/flagfox.jsm:70
    safeCall((function (addon) {try {FlagfoxVersion = addon.version;var ip4db = addon.getResourceURI(IPv4DBfilename).QueryInterface(Components.interfaces.nsIFileURL).file;var ip6db = addon.getResourceURI(IPv6DBfilename).QueryInterface(Components.interfaces.nsIFileURL).file;ipdb.init(ip4db, ip6db);checkIPDBage();ready = true;} catch (e) {handleStartupError(e);}}),null)@resource://gre/modules/AddonManager.jsm:48
    ([object Object])@resource://gre/modules/AddonManager.jsm:897
    AOC_callNext()@resource://gre/modules/AddonManager.jsm:118
    (null)@resource://gre/modules/AddonManager.jsm:892
    PL_getAddon("{1018e4d6-728f-4b20-ad56-37578a4de76b}",(function (aAddon) {if (aAddon) {safeCall(aCallback, aAddon);} else {aCaller.callNext();}}))@resource:///modules/PluginProvider.jsm:79
    callProvider([object Object],"getAddonByID",null,"{1018e4d6-728f-4b20-ad56-37578a4de76b}",(function (aAddon) {if (aAddon) {safeCall(aCallback, aAddon);} else {aCaller.callNext();}}))@resource://gre/modules/AddonManager.jsm:76
    ([object Object],[object Object])@resource://gre/modules/AddonManager.jsm:888
    AOC_callNext()@resource://gre/modules/AddonManager.jsm:124
    (null)@resource://gre/modules/AddonManager.jsm:892
    (null)@resource:///modules/XPIProvider.jsm:3047
    ([object Array])@resource:///modules/XPIProvider.jsm:4864
    (0)@resource:///modules/XPIProvider.jsm:3867
    BROWSER: Mozilla Firefox 7.0.1 (Gecko 7.0.1 / 20110928134238)
    OS: Windows NT 6.1 (WINNT x86-msvc windows)
    LOCALE: en-us content / en-us UI / en-us OS
    Select and copy the error report above. In order to fix this problem for you and others, please read and follow the troubleshooting and bug reporting instructions on the Flagfox support forums. Please post an abundance of information with any error reports, namely what you were doing at the time that may have triggered this. (English please)

  • In plain English can someone tell me how to use the unsubscribe button or get it to show up in the "unsubscribe from mailing list" ad-on?

    There's nothing to detail it doesn't work.

    In plain English.
    If the unsubscribe header the add-on uses is present it shows up in the mail header along with the from Subject to etc. With or Without the add-on. So if there is no entry in the header, then the mail sender does not support that style of unsubscribing. In the United States unsubscribing from a mailing list is troublesome as legislators are either are unable or unwilling to understand the problem. Given the amounts of money involved I will go with the latter.
    Any difficulties you have with the actual add-on need to be dealt with by the add-on author The download page list a support link. https://addons.mozilla.org/en-US/thunderbird/addon/unsubscribe-from-mailing-list/?src=search

  • Is there a plain English guide to sharing iCal Calendars via OSX Server Mountain Lion?

    Is there a plain English guide to sharing iCal Calendars via OSX Server Mountain Lion? The present documentation is very limited and of no assistance to a beginner like me.

    I don't have a domain set up on OSXServer  I just have server.myserver.private. I have no mail services at server.myserver.private. I uses [email protected] (a different server)  as the email address in the setup process.
    When I go to share the calendar it requires a valid email address, rather than [email protected], so I enter my email address as a test, I try many other email addresses too but the server responds with an error stating " (email adress) was not recognized by the server.  A new invitation has not been sent.

  • Business Rules to Plain English

    I remember hearing about this software to convert rules to plain English so users will understand them. Is this out there ?
    Thanks much for any help.

    I know of an object parser that extracts business rule information into document form - http://www.prweb.com/releases/prweb2012/11/prweb10172583.htm
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Displaying SQL Exception errors in plain english

    Hi,
    How can I display SQL Exception errors in plain english. For example how would I display:
    java.sql.SQLException: ORA00001:unique consraint(EMP.NAME) violated
    to
    Name already exists!
    Regards.

    When you log into SharePoint you give it a username and password, this might be automatic so you never notice it but it still happens in the background. The UPS then takes that username and creates a UPS entry for that account using information stored in
    Active Directory.
    If you're not familiar with AD it's normally a generally accessible 'phone book' like collection of user data like username, first name, surname, email address, manager, department and what security groups they belong to.
    If you configure the sync service this information is pulled through earlier in bulk rather than on-demand as users log in. You also get a lot more control over what data is used where and how.
    It's slightly different if you're using Forms Based Authentication but that's another story.

Maybe you are looking for

  • Issue with adding a new value to the Default Login Page

    Hopefully this is an easy one guys, I've added a select list item to the standard login page (P101) to allow the user to select a DOMAIN as well as entering their username and password. When the next page is displayed and I try to retrieve the value

  • Error msg in IF ELSE statement in jsp page, Need help

    Below is my code I am trying to execute, but keep getting an error: Compilation error occured: Found 1 errors in JSP file: D:\\http\\proFolder\\student.jsp:130: Syntax: "}" inserted to complete StatementNoShortIf <%if (assess.getNumberValue() > 0) {%

  • Helping fixing a script

    I was looking for a script that would relink 18 images to 18 new images in a different folder. I ran accross this script but the file names need to be the same and I'm getting an error line 21 (placedFiles.push(placedItems[i].file.name);). Could some

  • Network name keeps changing with Print Share

    I have 3 iMacs on a network using a Brother MFC-9840CDW printer. My computer is set for print sharing. I keep getting messages that the name of my computer is already in use on this network and it keeps adding a higher number at the end of the name.

  • Shopping cart - item status table

    Hi Friends, I have a requirement to develop a Z report which should include two status fields of Shopping Cart. One status column should show status at header level and the other should show status at item level. I am able to fetch the Status of the