I'm trying to sort a map by value. The data structure is as follows:  Map&lt;String, ArrayList&lt;Object&gt;&gt;   The ArrayList contains a set of properties for a set of objects whose name corresponds to the string key value in the map.   The idea is that I want to sort these objects by property. So, let's say that transparency was a property of these objects, and transparency is stored in ArrayList.get(3) for all objects.   How would I be able to sort it in a way such that:  I'm able to output:  Transparency     Object Name    Value            Name 1    Value            Name 2    Value            Name 3     Value            Name 4   I've tried a few different sorts, and nothing seems to be working.  Any ideas?   Edit: More information.  The objects inside the arrayList are all either Double type or String type, and I am defining the comparison between the two values through their default comparison. Essentially, I've organized the data like this:  The name of the object whose properties are contained in a list is the key for the map. The value given by the key is the list of properties for that object. I want to compare property(i), where i is user input, of Object A with property(i) of Object B, and then output them using System.out.print() or printf()
I am relatively new to Java, and often find that I need to sort a Map&lt;Key, Value&gt; on the values.  Since the values are not unique, I find myself converting the keySet into an array, and sorting that array through array sort with a custom comparator that sorts on the value associated with the key.  Is there an easier way?
Finding out the area of a triangle if the coordinates of the three vertices are given What is the simplest way to find out the area of a triangle if the coordinates of the three vertices are given in $x$-$y$ plane?   One approach is to find the length of each side from the coordinates given and then apply . Is this the best way possible?   Is it possible to compare the area of triangles with their coordinates provided without actually calculating side lengths? Integer $x$ for which $x^4+x^3+x^2+x+1$ is perfect square. Integer values of $x$ for which $\bf{x^4+x^3+x^2+x+1}$ is a Perfect Square.  $\underline{\bf{My\; Try}}$:: Let $\bf{x^4+x^3+x^2+x+1 = k^2}$, where $k\in \mathbb{Z}$  $4x^4+4x^3+4x^2+4x+1 = 4k^2 = (2k)^2$  Now How can I proceed after that  Help Required,  Thanks I have heard rumors that you can compile documents online, and more specifically that Google has a free online compiler, but I have never been able to find any. Is there a way to compile documents online, so that I can write and compile documents even if I don't have a TeX distribution installed on my computer? Often when I edit one of my answers, it's because I want to better address the original question. The only problem is that I can't see the original question while I'm editing my answer!  I'd love to see the original question text beneath the "answer edit" form. This way I could scroll down slightly to read it if I wanted to, or just ignore it if not.  Current workaround is to click the 'return to answer' link and hope that you remember to launch it in a new tab/window, then tab back and forth.    Imported from this uservoice item: I am trying to understand how complex numbers made their way into QM. Can we have a theory of the same physics without complex numbers? If so, is the theory using complex numbers easier? What is the difference between Fact and Truth? I'm curious about the difference between Fact and Truth. I was searching on the internet if I could find it. But still I'm confused about the exact meaning. I first read the forum discussion here  where an author has given two examples for each like below     A fact is a reality that cannot be logically disputed or rejected. If   I say "fire is hot," I don't care how great your reasoning skills are,   if you touch fire your skin will burn (and don't give me that "but   people can walk on hot coals!" bull. There's a difference between the   transfer of heat through conduction and training one's body to deal   with the agonizing pain of said conduction). Now when I say this, I am   not speaking a truth, I am speaking a fact. If you say "fire is not   hot," you are not lying, you are incorrect. Facts are concrete   realities that no amount of reasoning will change. When one   acknowledges a fact, they are doing just that. Facts are not   discovered, facts are not created, facts are simply acknowledged.      A truth on the other hand, is almost the opposite. Truths are those   things that are not simply acknowledged, but must be discovered, or   created. If I say "God exists," and I possess strong reasoning for the   affirmative of that statement, then God really does exist, that is a   reality. However, if another individual possesses strong reasoning for   the negative, and because of this reasoning they believe that God does   not exist, then that is also a reality. If we were to debate our   ideologies, and my reasoning appeared stronger than theirs, they may   choose to adopt my belief that God does exist. If they do, then the   existence of God is just as true as the nonexistence of God which they   believed a week ago. Truths, as opposed to fact, are much more fluid   and malleable than their empirical counterparts.   and followed by further discussion.  Then I found this . Article from above link says like below:     Facts are notes and lyrics on sheet music.  Truth is what the singer   gives to the listener when she’s brave enough to open up and sing from   her heart.   But still curious about the difference between both of them.  In our daily life, in general conversation, we generally use these both terms interchangeably. Then what is the difference? Are they synonym or have specific difference? How do I change my Chrome language back to English? DMed for the first time yesterday and one of the things I feel I need to sort out, among other comments, improvements, and similar, is how combat itself is actually initiated. The main example I want to use involves  attempting to generate surprise conditions by players. Here the characters have entered a ruined city and generally been noisy about the whole thing - using a spell to make their voice louder and literally ask if there is anyone about. Any enemies around probably know what something is about to kick off but arguably don't know precisely what. After resting the PCs head up a long flight of steps to a temple on the edge of the city. At the top only one crests and finds 3 bandits lounging around, chatting, and doing whatever bandits do in their spare time. After a brief exchange of pleasantries a combat starts:  DM &quot;The bandit spits in your direction 'we're not done looting the temple, so you can clear off', and starts raising his crossbow as his mates emerge from their cover behind the pillars... PC &quot;I cast Firebolt at Bandit Keith&quot; DM &quot;Hang on, I hadn't finished, everyone rolls for initiative...  Which sparked a debate about whether or not the PC could preemptively cast/attack before the combat starts by &quot;instant actioning&quot; (as above) as I was describing the start of the combat. As far as the bandits are concerned a lone half-elf who is pretty heavily armed has popped up in front of them, not even tried to be diplomatic, and ended up saying something rather suggestive about their mothers. The PC then asked about it being &quot;surprise&quot; because the bandits wouldn't necessarily expect an attack, but my view of &quot;surprise&quot; is closer to an ambush where one party is unaware of the other's existence. (This precise example is close to how  works, however this specific PC was always the first of the party to go into rooms (only one with darkvision) and consistently felt they should get free rounds at the start of combat based on declaring attacks before I could &quot;start&quot; the combat.) The second example the party came to more bandits, who were not alert immediately, in an underground room. They used magic to yell something obscene at the bandits and shut off all the torches so the bandits were effectively blinded. At this point they wanted to burst into the room casting spells, swinging maces, and playing some &quot;meaty chords&quot; (the bard's words, not mine). Again they wanted surprise arguing that, despite the fact that the bandits were yelling and cursing in confusion, they couldn't be sure they were actually being attacked as such. In the end a character with darkvision wanted to sneak in to a corner and again wanted surprise based on passing stealth rolls, so they would start the &quot;combat&quot; by firing a crossbow. At that point I think I relented because it was clear that they would do anything to try and win combats in a single round. In a nutshell, my question is: &quot;how liberally can the concept of surprise be applied to combat - is it only when one party is literally unaware of a threat (as I read the rules), or just when they are caught slightly off guard by the exact situation?&quot; NB I already plan to address the attempts at interrupting descriptions with actions next session, because it happened at other times and actually threw me off quite a bit. How to defer variable expansion I was wanting to initialize some strings at the top of my script with variables that have no yet been set, such as:  str1='I went to ${PLACE} and saw ${EVENT}' str2='If you do ${ACTION} you will ${RESULT}'   and then later on PLACE, EVENT, ACTION, and RESULT will be set. I want to then be able to print my strings out with the variables expanded. Is my only option eval? This seems to work:  eval "echo ${str1}"   is this standard? is there a better way to do this? It would be nice to not run eval considering the variables could be anything. Where are the proprietary NVIDIA drivers in 16.04? The proprietary NVIDIA drivers "disappeared" with my latest update:    The option of "Proprietary drivers for devices" is correctly set under the "Ubuntu Software" tab. I have the graphics-driver PPA (ppa:graphics-drivers/ppa) correctly added to my sources.  Any ideas on how to bring the proprietary drivers back?  PS1: I need them because some of the games I play under wine don't work without them, for whatever reason.  PS2: Also, this feels like it should have a straightforward answer, but I've been looking online for a while without luck. Passing list to viewparams variables in GeoServer SQL views? I have a sql view which take only one parameter, but this parameter is a list, and a need to know how can i pass this parameter in the url  Here is my sql view  SELECT * FROM shop WHERE id IN %list%   When I put the default value for %list% as (1, 2 ,3) as example, the layer preview works and show the shopa with the default ids,  but when I try this in the url  viewparams=list:(1,2,3)   does not work.   I already tried other things like   viewparams=list:"1,2,3"   but nothing works.  Does anyone know how to do this? If a linear operator has an adjoint operator, it is bounded $GL_n(\mathbb F_q)$ has an element of order $q^n-1$ For fixed prime power $q$ show that the general linear group $GL_n(\mathbb F_q)$ of invertible matrices with entries in the finite field $\mathbb F_q$ has an element of order $q^n-1$.   I tried to show this question with showing diagonal matrix but i can't find element directly  competible with order i think i am on wrong way please give me clue ? "With what [...]?" or "What [...] with?" Making a comparison with Who/Whom I now have a question about the use of what with prepositions in questions. I'll explain by example:  These two sentences are correct, one is more formal than the other:  Who/Whom     Formal: With whom are you doing that? Informal: Who are you doing that with?   But if I substitute Who/Whom with What, the "formal" one sounds a bit awkward and I'm not sure if it's correct or not:  What     With what are you doing that? What are you doing that with?   So, are those last two questions grammatically correct? Is one more formal than the other? How do I install pillow in Ubuntu 16.04 LTS? I went to  for installing Pillow since the original PIL is a discontinued project and so now not so good to use. But, in the table support for Ubuntu 16.04 LTS is unmentioned. It appears neither in , or in .     Further, just installing pillow is said to be not enough. There are some dependencies that should be installed first which is also unmentioned for Ubuntu 16.04 LTS. Would the installation steps for Pillow for python 3 given for 14.04 LTS be OK for Ubuntu 16.04 LTS?  If not, How do I install pillow in 16.04 LTS for Python 3.6? (There is support for Python 2.) Is my US visa still valid after change in name? failed to get D-Bus connection: Operation not permitted I'm trying to list services on my CentOS image running in Docker using  systemctl list-units     but I get this error message:  Failed to get D-Bus connection: Operation not permitted   Any suggestions what the problem might be? I've just made a set of armor by using a male body mesh model I downloaded and selecting certain faces from the model and duplicating them to create viable armor pieces.   Since the pieces are just duplicated from the same mesh male model, then it's still part of the same object.   How do I separate the armor piece from the model to make the pieces separate? Proof of $A\cap(B\cup C) = (A\cap B)\cup(A\cap C)$ Trying to find the original story (I read it in Russian translation, original was most likely English unless it was Lem).  The story plot had artificial birds designed to serve as cops. The birds started attacking humans who were percieved as being aggressive towards anything alive. So they created more advanced birds to protect against the first ones. This worked for a while until the second kind started attacking humans as well. It ended with the idea that they would need another generation to attack the second-generation birds.  The story wasn't very long. I read it a while back (mid-1980s, which means the original was written even earlier, probably before 1980).  Despite a somewhat Asimov-like "misbehaving robots" topic, I'm pretty sure it wasn't Asimov.