Python sorting a dictionary by values based on key From what I understand, you can sort a dictionary by items, keys, and values which will then show the respected part in a sorted list   sorted( d.items...) shows the entire entry, keys to keys, and values to values.  How would I go about showing only the values in a dictionary based on the key being sorted?  I've tried  sorted(d.values(), key = (lambda x:...) - but I'm not sure if I'm going about this the right way  d = { 2: (4,6) , 5: (3,2), 3: (5,9) } would be an example of a dictionary and I want it to display   { (4,6), (5,9), (3,2) } - ordered based on key but only show values.  I'm trying to only use the sorted function and not import anything else
How do I sort a dictionary by value? I have a dictionary of values read from two fields in a database: a string field and a numeric field. The string field is unique, so that is the key of the dictionary.  I can sort on the keys, but how can I sort based on the values?  Note: I have read Stack Overflow question here  and probably could change my code to have a list of dictionaries, but since I do not really need a list of dictionaries I wanted to know if there is a simpler solution to sort either in ascending or descending order.
What is the difference between [@] and [*] when referencing bash array values? says:  If the index number is @ or *, all members of an array are referenced.  When I do this: LIST=(1 2 3) for i in &quot;${LIST[@]}&quot;; do   echo &quot;example.$i&quot; done  it gives the desired result: example.1 example.2 example.3  But when I use ${LIST[*]}, I get example.1 2 3  instead. Why? Edit: when using printf, @ and * actually do give the same results. What is this type of flexible contact strip called? The LCD below is from a cheap digital clock which was (obviously) damaged (broken glass).    The electrical connection between the PCB and the display was realized with this pink strip.    Its flexible...    ...and consists of alternating rows of conductive and insulating material between the pink boarders.    [above image was altered in contrast/brightness to highlight the alternating strips]  What is this kind of connector called? Is it only used for displays?   I am pretty impressed that the connection is reliable just from the very slight pressure between the strip and the PCB. Also, its easily removable from the display. There seems to be some conductive layer on the glass, from where the signal goes into the displays internals. This connection seems to be damaged for the three rightmost signals, where the glass is broken. Understanding the -exec option of `find` How to prove that the only subgroup of the symmetric group $S_n$ of order $n!/2$ is $A_n$?  Why isn't there other possibility?  Thanks :) Calculate daily sums using python pandas How to fix sculpting ridges? I ran into a problem I have never seen before and that is when I try to sculpt on a mesh, it sculpts like this:  Instead of this: I am using dyntopo with these settings:   I feel like theres a very obvious solution to this, but I have no idea what it is. Machine learning cookbook / reference card / cheatsheet? I find resources like the  and  incredibly useful. They obviously serve well as references but also help me to organize my thoughts on a subject and get the lay of the land.   Q: Does anything like these resources exist for machine learning methods?  I'm imagining a reference card which for each ML method would include:   General properties When the method works well When the method does poorly From which or to which other methods the method generalizes. Has it been mostly superseded? Seminal papers on the method Open problems associated with the method Computational intensity   All these things can be found with some minimal digging through textbooks I'm sure. It would just be really convenient to have them on a few pages. Is there a new auto-login feature? NoSuchMethodError error for getActionBar() (API-8) Why is part of my model not being rendered? If $f(x)$ is differentiable at x, I need to prove that $\lim_{h\to0}\frac{f(x+h)-f(x-h)}{2h}$ exist and is finite.  so if $f(x)$ is differentiable at a $x$, the difference quotient exist for this point, and also $f(x)$ must be continuous at x as well  so that mean that:  $\lim_{h\to0^+}\frac{f(x+h)-f(x)}{h} =  \lim_{h\to0^-}\frac{f(x+h)-f(x)}{h}$  and that: $\lim_{x\to x_0^+}=\lim_{x\to x_0^-}=f(x_0)$  I know I should probably use arithmetic limit laws to prove this but I can't see how what I figured out could help me. any help with that?  Thanks! I have messed up my sudoers file and I want to change the permission on it.   When I login in recovery mode, I cannot run the command chmod as it is read-only option.  I tried mount -o remount,rw / in recovery mode. Didn't work for me:  Err : Ext4-fs remount. Opts errors=remount-ro    How can I boot into recovery mode and with read-write option? Basically, I have a kindle fire that uses a form of the android OS and was wondering if there was a way I could run similar apps on my Ubuntu system. Specifically I'd like the news reader program "Pulse".  Anybody know if such an emulator or workaround exists? I'd like to write something in the shape of this "coat of arms".    I'd like to have the text filling the coat but with a hole roughly in the shape of the sword. I know there is the \shapepar command to create paragraph shapes so I tried to , a patch for XFig that allows you to draw the shape you want but it never worked on my computer (Mac OS X). I also know I can build the shape by myself with shapepar syntax but it seems really complicated and I don't think I'll make a lot of shapes. So if anybody has ShapePatch working on his computer or knows shapepar syntax very well, could he give me the code? Stop all active ajax requests in jQuery Are Windows file timestamps timezone aware? How do the definitions of "irreducible" and "prime" elements differ? Update: Universal login is in place and considered &quot;done&quot;. If you see anything weird, please submit new bug reports.   As y'all know, our current flavor of &quot;global authentication&quot; leaves a few things to be desired. It's flaky, requires a page refresh, etc. etc. Wouldn't it be nice if you could just sign in once and be automatically logged in across the network?  We are ready to roll out Stage 1 of Project &quot;Make Authentication Suck Less&quot;. It is live as of a few minutes ago. What this means right now:  When you log into any Q&amp;A site on the stackexchange.com domain, you will be automatically logged into all other Q&amp;A sites on the stackexchange.com domain + stackexchange.com itself.   is excluded from this.   , , and other Q&amp;A sites with their own domains will still use the old flow.  We are going to recognize you in some ways on sites where you don't have a profile. This is still a work in progress, but most notably you will see &quot;join this community&quot; in the top bar instead of &quot;sign up&quot; and &quot;log in&quot;.   But I use multiple accounts! What do? We aren't intending to break the ability to run multiple accounts. The same guidelines as before still apply — we don't officially support that, you might end up with an accidental automatic merge if you're not careful with your credentials, any interaction between the accounts is right out, and so on. If you're already using different browsers or different browser profiles for your accounts, nothing will change for you. If you are somehow logged into multiple accounts in the same browser... I'm sorry to say, but that's a bug even for our current global auth setup. You will now only be able to log into one at a time, and you'll need to log out when you want to switch. (Or start using different browsers.) What's next:  Remember  we tested a few months ago? It's coming back. Stage 2: bring other domains into the fold (this is also live now) Stage 3: make cross-domain experience smoother and support browsers that reject third-party cookies in all conditions (looking at you, Safari) - this is not currently feasible. Safari users and users who reject third-party cookies will need to sign in separately to every second-level domain (e.g. stackexchange.com, stackoverflow.com, etc).  If you see any issues… Good luck, because you probably can't log in to report them here. =) But seriously, let us know via the contact form linked at the bottom of any page. If you are able to log in, report issues here on meta as normal. So, in conclusion… Splitting a string into words and punctuation I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.  For instance:  &gt;&gt;&gt; c = "help, me" &gt;&gt;&gt; print c.split() ['help,', 'me']   What I really want the list to look like is:  ['help', ',', 'me']   So, I want the string split at whitespace with the punctuation split from the words.  I've tried to parse the string first and then run the split:  &gt;&gt;&gt; for character in c: ...     if character in ".,;!?": ...             outputCharacter = " %s" % character ...     else: ...             outputCharacter = character ...     separatedPunctuation += outputCharacter &gt;&gt;&gt; print separatedPunctuation help , me &gt;&gt;&gt; print separatedPunctuation.split() ['help', ',', 'me']   This produces the result I want, but is painfully slow on large files.  Is there a way to do this more efficiently? A type-I superconductor can expel almost all magnetic flux (below some critical value $H_c$) from its interior when superconducting. Light as we know is an electromagnetic wave. So what would happen if we shine a light deep into a type-I superconductor? Suppose the magnetic field of the light is significantly lower than $H_c$.  And what about type-II superconductors?