I don't think that's the best way to word that title but I can't think of a better way to word it. Here's my problem: I have to write a method that compares in several different ways. If the last names are the same, I then need to compare by first name. If the first names are the same, then I need to sort by section. What would be the most effective way to sort a data structure in this hierarchy? Here's what I've currently got and I think I understand why it doesn't work but I can't come up with a different way to write this function:  //Student class structure, each field has a public get/set method public class Student implements Comparable&lt;Student&gt; {   private String fname;   private String lname;   private int section; }  //My current compareTo method @Override public int compareTo(Student s) {   /*     -compare by last name     -if the same, compare by first name     -if the same, compare by section   */    String slast = s.getLastName();    if(lname.compareTo(slast) == 0)   {     String sfirst = s.getFirstName();      if(fname.compareTo(sfirst) == 0)     {       int sclass = s.getSection();        return Integer.compare(section, sclass);     }      else     {       return fname.compareTo(sfirst);     }   }    else   {     return lname.compareTo(slast);   } }
Assume you have some objects which have several fields they can be compared by:  public class Person {      private String firstName;     private String lastName;     private String age;      /* Constructors */      /* Methods */  }   So in this example, when you ask if:  a.compareTo(b) &gt; 0   you might be asking if a's last name comes before b's, or if a is older than b, etc...  What is the cleanest way to enable multiple comparison between these kinds of objects without adding unnecessary clutter or overhead?   java.lang.Comparable interface allows comparison by one field only Adding numerous compare methods (i.e. compareByFirstName(), compareByAge(), etc...) is cluttered in my opinion.   So what is the best way to go about this?
The additive group $\mathbb{G}_a$ over an infinite field $k$ is not a topological group An algebraic group is not necessarily a topological group, since for an algebraic group, the product map $G \times G \to G$ is continuous when $G \times G$ is given the Zariski topology, which is finer than the product topology.   So does this tell you that the additive group $\mathbb{G}_a$ over an infinite field $k$ is not a topological group? The underlying variety of $\mathbb{G}_a \times \mathbb{G}_a$ is $\mathbb{A}_k^1 \times_k \mathbb{A}_k^1 = \mathbb{A}_k^2$, whose Zariski topology is the cofinite topology, where every open set is also open in the product topology (since $\mathbb{A}_k^1$ also has the Zariski topology). Statistical significance (p-value) for comparing two classifiers with respect to (mean) ROC AUC, sensitivity and specificity I have a test set of 100 cases and two classifiers.  I generated predictions and computed ROC AUC, sensitivity and specificity for both classifiers.  Question 1: How can I compute p-value to check if one is significantly better than the other with respect to all scores (ROC AUC, sensitivity, specificity)?    Now, for the same test set of 100 cases, I have different and independent feature assignments for each case. This is because my features are fixed but subjective and provided by multiple (5) subjects.  So, I evaluated my two classifiers again for 5 "versions" of my test set and obtained 5 ROC AUCs, 5 sensitivities and 5 specificities for both classifiers. Then, I computed the mean of each performance measure for 5 subjects (mean ROC AUC, mean sensitivity and mean specificity) for both classifiers.  Question 2: How can I compute p-value to check if one is significantly better than the other with respect to mean scores (mean ROC AUC, mean sensitivity, mean specificity)?    Answers with some example python (preferably) or MatLab code are more than welcome. How to deal with very long lines that do not contain spaces? Who was the piano player that Starbuck met in the bar on Galactica? Towards the end of season four, Starbuck meets a piano player in the makeshift bar on Galactica.  Now, it appears that this guy is some kind of ghost/angel like Caprica-6 and the ghost Baltar - but I have an idea that he could also be the original copy of the seventh model (Daniel). It's mentioned right in the episode before that Cavil poisoned all of the bodies that were being prepared to accept a copy of Daniel - but it's ambiguous about the fate of the original cylon with that personality. Daniel was also mentioned as an 'artist' and 'sensitive' person.  So - could it have been Daniel that helped Starbuck realise what the music meant? Show/Hide hidden files without restarting finder? I came to understand that the following is the way to toggle the visibility of hidden files:  defaults write com.apple.finder AppleShowAllFiles YES # replace YES with NO to hide hidden files killall -HUP Finder /System/Library/CoreServices/Finder.app   Is there a way to show/hide hidden files without killing the Finder? Why didn't Thor lose his power? In Thor: Ragnarok, Valkyrie told Thor this about Hela:  Her power comes from Asgard the same as yours  Thor's plan was to unleash Surtur who destroys Asgard, which weakens Hela allowing Surtur to kill her. But why didn't that weakened Thor as well? We saw him later in Avengers: Infinity War very powerful. How many complements are in "I ask you to clean the room"? How many complements are needed in the below sentence?     "I ask you to clean the room."   This sentence above has one complement or two complements? Sum of First $n$ Squares Equals $\frac{n(n+1)(2n+1)}{6}$ I've just begun to work learn Linear Algebra on my own through Hoffman and Kunze's book and the first problem set already has a question that I can't solve:  Prove that if two homogeneous systems of linear equations in two unknowns have the same solutions, then they are equivalent.  I can't seem to figure out how to prove this without resorting to case work where you account for the cases where one of the coefficients are zero and when both are.  Is there an elegant way to prove in general that when two systems of linear equations have the same solutions, they are equivalent? The converse is obvious enough though.  Definition of equivalence from the text :     Let us say that two systems of linear equations are equivalent if each equation in each system is a linear combination of the equations   in the other system. How should I use "eponym", "eponymous" and "namesake"? I was in London and visited the Tower Bridge. Afterwards, I went to a pub called The Tower Bridge. Just to be clear, the pub is named after the bridge.   Which of the following are correct?   The bridge is the eponym of the pub. The pub is the eponym of the bridge. From the pub, I could see the eponymous bridge. After I saw the bridge, I went to the eponymous pub. The bridge is the namesake of the pub. The pub is the namesake of the bridge. I'm trying to parse json response.. but keep getting this error      Invalid conversion from runtime type List ANY> to Map String,ANY>   Map&lt;String, Object&gt; MapLv3 = new Map&lt;String, Object&gt;();      Integer x2 = 0; for (Object oh : CallsList){     MapLv3.put(String.valueof(x2), oh);     x2++; } index = x2; System.debug('Map Lv 3 ==&gt;'+MapLv3);  Map&lt;String, Map &lt;String, Object&gt;&gt; Map3 = new Map&lt;String, Map &lt;String, Object&gt;&gt;(); for (Integer a2 = 0; a2 &lt; index; a2++){     Map3.put(String.valueof(a2),(Map&lt;String,Object&gt;) MapLv3.get(String.valueof(a2))); } System.debug('Segment ==&gt;'+Map3.get('0').get('segments')); Let us denote by $\chi(G)$ the chromatic number, which is the smallest number of colours needed to colour the graph $G$ with $n$ vertices. Let $\bar{G}$ be the complement of $G$. Show that  (a) $\chi(G)+\chi(\bar{G}) \leq n+1$  (b) $\chi(G)\chi(\bar{G}) \geq n$  I was able to prove (a) using induction. Any hints on proving (b)? I've deleted a system file from my Mac and need to get it back.  System files can include:   hidden files in the root of / - especially unix files in /private  /System files /Library files /Applications files that ship with the core OS   System files are not any app, user files or files that can be regenerated by a known sequence such as cache files, Spotlight index files, etc…    Canonical question and answer for . Show $\,p\mid 9^q -1 \implies q\mid p-1$ for odd primes $p$ and $q$ If $p$ and $q$ are odd primes show that $$p|(9^q -1) \implies q|(p-1).$$ ....  I am having difficulty to prove this.  Yes that was the question I have misunderstood between 9 and q!!! How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name? Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date. See @npocmaka's     What's a Windows command line statement(s) I can use to get the current datetime in a format that I can put into a filename?  I want to have a .bat file that zips up a directory into an archive with the current date and time as part of the name, for example, Code_2008-10-14_2257.zip. Is there any easy way I can do this, independent of the regional settings of the machine?  I don't really mind about the date format, ideally it'd be yyyy-mm-dd, but anything simple is fine.  So far I've got this, which on my machine gives me Tue_10_14_2008_230050_91:  rem Get the datetime in a format that can go in a filename. set _my_datetime=%date%_%time% set _my_datetime=%_my_datetime: =_% set _my_datetime=%_my_datetime::=% set _my_datetime=%_my_datetime:/=_% set _my_datetime=%_my_datetime:.=_%  rem Now use the timestamp by in a new ZIP file name. "d:\Program Files\7-Zip\7z.exe" a -r Code_%_my_datetime%.zip Code   I can live with this, but it seems a bit clunky. Ideally it'd be briefer and have the format mentioned earlier.  I'm using Windows Server 2003 and Windows&nbsp;XP Professional. I don't want to install additional utilities to achieve this (although I realise there are some that will do nice date formatting). Suggestions for a batch audio converter? Any suggestions for a good, free audio converter for Mac?  I used to use Max.app but it has long become abandonware and is now super buggy and crashy. I just need something I drop a couple (or 20 thousand) Apple Lossless files into and let it crank away making me some AAC compressed files or some MP3 or whatever. I accidentally "always ignore"d a wrong wrong word. How do I undo it and make the old dictionary clean again? How to use WiFi and Ethernet at the same time Brief Description:  I need my Ethernet card (en0) to see all traffic under 192.168.2.xxx.  However I also need to use WiFi card (en1) for all other traffic.  OS: OS X Lion    I am using a separate network location to deal with this specific use (since this is a for a robotics project that communicates via Ethernet). Ethernet (en0) had to be set up as a static IP (192.168.2.10) per the requirements for the device I am connecting to. All connections on the Ethernet card (en0) should be 192.168.2.xxx as specified above. WiFi (en1) is set up as DHCP to a router since their is no point in assigning it as a static for general purpose traffic. Ethernet (en0) is set up as priority over WiFi (en1).  I would also like to keep this under the network location preferences if at all possible since I do not require this feature to be on all the time.  I would really appreciate your help on this. No one I have talked to knows how to solve this. What longest time ever was achieved at holding light in a closed volume? For what longest possible time it was possible to hold light in a closed volume with mirrored walls?   I would be most interested for results with empty volume but results with solid-state volume may be also interesting. Plotting the function $f(x)=x^{1/3}$ defined for any real number $x$ gives us:   Since $f$ is a function, for any given $x$ value it maps to a single y value (and not more than one $y$ value, because that would mean it's not a function as it fails the vertical line test). This function also has a vertical tangent at $x=0$.   My question is: how can we have a function that also has a vertical tangent? To get a vertical tangent we need 2 vertical points, which means that we are not working with a "proper" function as it has multiple y values mapping to a single $x$. How is it possible for a "proper" function to have a vertical tangent?  As I understand, in the graph I pasted we cannot take the derivative of x=0 because the slope is vertical, hence we cannot see the instantaneous rate of change of x to y as the y value is not a value (or many values, which ever way you want to look at it). How is it possible to have a perfectly vertical slope on a function? In this case I can imagine a very steep curve at 0.... but vertical?!? I can't wrap my mind around it. How can we get a vertical slope on a non vertical function?