In a graph i associate a node to a quantity : quantities could be redundant and nodes can't, so in order to sort according to ascending quantities i put nodes as keys and quantities as values of a LinkedHashMap and sort it as follows :  LinkedHashMap&lt;Node, Integer&gt; orderedResult = mapNameToSize.entrySet()                 .stream()                 .sorted(Map.Entry.comparingByValue())                 .collect(Collectors.toMap(                         Map.Entry::getKey,                         Map.Entry::getValue,                         (oldValue, newValue) -&gt; oldValue, LinkedHashMap::new));  But my question is how to get the keys sorted accordingly into a ArrayList?
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?
Do I need Transit Visa to visit London for 4-5 hours during layover? How to add a loopback interface? I want to add two more loopback interfaces.  I used the following command:  ifconfig lo: 127.0.0.2 netmask 255.0.0.0 up   and type in ifconfig, i can see the loopback address was added.  But if i want to add one more interface... (for example 127.0.0.3) the previous interface (127.0.0.2) was overwritten.  Also when i look in /etc/network/interfaces i see no entry.  How can i add multiple loopback interfaces permanently? Why split the  tag when writing it with document.write()? Continuous function whose right hand derivative equals 0 is constant? Why is (sizeof(int) > -1) false? How to put a '+' sign inside a square like xor How did a new question with a title shorter than 15 characters come to exist? Find the value of $\sum_{k=1}^{n}k\binom{n}{k}$ ?    I know that $\sum_{k=0}^{n}\binom{n}{k}= 2^{n}$ and so, $\sum_{k=1}^{n}\binom{n}{k}= 2^{n}-1$ but how to deal with $k$ ? Is there a Ubuntu sanity check? Is there a standard procedure to 'unit test' an Ubuntu system against the deb packages?  Assume, a system has ubuntu-desktop installed according to the package manager. Can I find out, whether the file system has all the files in ubuntu-desktop and dependencies?   related question: I am working on a git repository with a master branch and another topic branch. I have switched to topic branch and modified a file. Now, if I switched to master branch that same file is shown as modified.   For example:  git status in git-build branch:  # On branch git-build # Changes to be committed: #   (use "git reset HEAD &lt;file&gt;..." to unstage) # #       modified:   cvsup_current #   Switch to master branch  [root@redbull builder_scripts (git-build)]# git co master M       builder_scripts/cvsup_current Switched to branch "master"   git status in master branch  [root@redbull builder_scripts (master)]# git status # On branch master # Changes to be committed: #   (use "git reset HEAD &lt;file&gt;..." to unstage) # #       modified:   cvsup_current #   Why is that the file is shown as modified in master branch even though it was modified in git-build branch?   My understanding was that the branches are independent of each other and when I change from one branch to another the changes do not "spill over" from one branch to another. So I am obviously missing some thing here.   Anyone got a clue stick? Irreducibility of an infinite sequence of polynomials I'm using using algorithm2e package with the following settings:  \usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}   But for some subset of algorithms in the same document, I want to use this setting:  \usepackage[boxed]{algorithm2e}   Is there a way to override the default setting just for a subset?  I found a similar question:  Here newenvironment is used to override the default setting of an option. But I want to override the option itself.  I wish there was a way to load a package several times with different options for each instance. Developing Unit Tests While Refactoring Legacy Code? Solving of a seperable differential equation How can I check for Python version in a program that uses new language features? If I have a Python script that requires at least a particular version of Python, what is the correct way to fail gracefully when an earlier version of Python is used to launch the script?  How do I get control early enough to issue an error message and exit?  For example, I have a program that uses the ternery operator (new in 2.5) and "with" blocks (new in 2.6).  I wrote a simple little interpreter-version checker routine which is the first thing the script would call ... except it doesn't get that far. Instead, the script fails during python compilation, before my routines are even called. Thus the user of the script sees some very obscure synax error tracebacks - which pretty much require an expert to deduce that it is simply the case of running the wrong version of Python.  I know how to check the version of Python. The issue is that some syntax is illegal in older versions of Python. Consider this program:  import sys if sys.version_info &lt; (2, 4):     raise "must use python 2.5 or greater" else:     # syntax error in 2.4, ok in 2.5     x = 1 if True else 2     print x   When run under 2.4, I want this result  $ ~/bin/python2.4 tern.py  must use python 2.5 or greater   and not this result:  $ ~/bin/python2.4 tern.py    File "tern.py", line 5     x = 1 if True else 2            ^ SyntaxError: invalid syntax   (Channeling for a coworker.) How to create a scope? I'd like to create a custom scope that searches and returns results from an online source for personal use.  Is this possible? And if so, how? Let $E$ be a Banach space, $\mathcal B(E)$ the Banach space of linear bounded operators and $\mathcal I$ the set of all invertible linear bounded operators from $E$ to $E$. We know that $\mathcal I$ is an open set, and if $E$ is finite dimensional then $\mathcal I$ is dense in $\mathcal B(E)$. It's not true that $\mathcal I$ is dense if we can find $T\in\mathcal B(E)$ injective, non surjective with $T(E)$ closed in $E$, since such an operator cannot be approximated in the norm on $\mathcal B(E)$ by elements of $\mathcal I$ (in particular $E$ has to be infinite dimensional).  So the question is (maybe a little vague): is there a nice characterization of $\overline{\mathcal I}^{\mathcal B(E)}$ when $E$ is infinite dimensional? Is the case of Hilbert space simpler? Full-wave bridge rectifier with capacitor filter and ripple voltage According to various sources, the ripple voltage of a full-wave bridge rectifier is   $$ V_r = \frac{V_s}{2}fCR $$  where \$V_s\$ is the peak of the input voltage source, \$f\$ is the frequency, \$C\$ is the capacitor and \$R\$ the resistor.  I have simulated this circuit on PSPICE, circuitlab, and built it in real life:   \$R\$ is \$4.7K\$ and \$C\$ is \$10 uF\$. Voltage source is sine wave with \$0 V\$ offset, \$5V\$ amplitude and \$40 Hz\$ frequency.  All 3 experiments give me a ripple voltage of approximately \$0.65V\$, but the formula gives me \$1.330 V\$ (twice as much).  What am I missing? How to embed a text file in a .NET assembly? I would like to embed a text file in an assembly so that I can load the text without having to read it from disk, and so that everything I need is contained within the exe. (So that it's more portable)  Is there a way to do this?  I assume something with the resource files?  And if you can, how do you do it and how do you programaticaly load the text into a string? Is it worth self-funding a PhD to attend a top 10 university? What should I opt for?   Option A) very well paid PhD, around €3000 per month at a respectable university or;  Option B) a non-paid PhD, where I have to pay €2000 per year at one of the top 10 universities of the world?  EDIT: Actually they are both UK universities, Option B  is ranked between the top 10 in the world in engineering and tech, and I do get a scholarship that pays 18000 pounds which covers the difference between international student tuition and EU tuition. In Option A, I will be doing research in a good university and will be working alongside giants in the industry.