How to sort a table of data in python? For some reason I have an unsorted table of data (just regarding to the first two columns) as following:  1 2 0.9 2 2 0.4 3 3 0.3 1 3 0.4 1 1 0.5 2 3 0.9 2 1 0.9 3 1 0.8 3 2 0.9   To plot this properly in python (with imshow at matplotlib) I need to sort the content as following:  1 1 ? 1 2 ? 1 3 ? 2 1 ? 2 2 ? 2 3 ? 3 1 ? 3 2 ? 3 3 ?   question mark is the related values for the third column.  In another hand, if somebody knows about how to use imshow to plot unsorted data tables that would be helpful too. Think about the following data table as a 3x3 table coordinated by the first two columns and the content of each components is indicated by the value of in the 3ed column by a color.
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.
PHP: How do I loop through every XML file in a directory? Why do we use this definition of "algebraic integer"? A number is an &quot;algebraic integer&quot; if it is the root to a monic polynomial with integer coefficients. Artin says (Algebra, p. 411):  The concept of algebraic integer was one of the most important discoveries of number theory. It is not easy to explain quickly why it is the right definition to use, but roughly speaking, we can think of the leading coefficient of the primitive irreducible polynomials $f(x)$ as a &quot;denominator.&quot; If $\alpha$ is the root of an integer polynomial $f(x)=dx^n+a_{n-1}x^{n-1}...$ then $d\alpha$ is an algebraic integer, because it is a root of the monic integer polynomial $x^n + a_{n-1}x^{n-1} + ... + d^{n-1}a_0$. Thus we can &quot;clear the denominator&quot; in any algebraic number by multiplying it with a suitable integer to get an algebraic integer.  When I first learned of algebraic integers, I looked online and saw some hints that maybe they were used to prove the Abel-Ruffini theorem. So I put off questioning their usage for a while; I now think I understand one proof of this theorem (the one at the end of Artin's Algebra) and it has nothing to do with algebraic integers (that I can tell). So basically: why is it important if a number is an algebraic integer? I think I understand what he's saying about the relationship between roots of integer polynomials and algebraic integers, but I fail to see why this is &quot;one of the most important discoveries of number theory.&quot; Is it possible to bake dupliverts into one mesh for the BGE? (I have a large ground landscape that I use as the parent to duplicate trees, and the BGE doesn't support most modifiers.) Is there a good tool/program that allows me to clone a system drive to another, smaller hard drive?  I've bought a new 64GB SSD drive and would like to move my current Windows 7 Professional 64-bit installation to that new drive. My current drive is a 200GB SATA drive with one partition only. Of course there's enough free space to shrink my current partition to less than 64GB. Area of an ellipse. (Calculus) Suppose I attach an blur function to an HTML input box like this:  &lt;input id="myInput" onblur="function() { ... }"&gt;&lt;/input&gt;   Is there a way to get the ID of the element which caused the blur event to fire (the element which was clicked) inside the function? How?  For example, suppose I have a span like this:  &lt;span id="mySpan"&gt;Hello World&lt;/span&gt;   If I click the span right after the input element has focus, the input element will lose its focus. How does the function know that it was mySpan that was clicked?  PS: If the onclick event of the span would occur before the onblur event of the input element my problem would be solved, because I could set some status value indicating a specific element had been clicked.  PPS: The background of this problem is that I want to trigger an AJAX autocompleter control externally (from a clickable element) to show its suggestions, without the suggestions disappearing immediately because of the blur event on the input element. So I want to check in the blur function if one specific element has been clicked, and if so, ignore the blur event. Consequence of the Hahn-Banach Theorem From wikipedia's page on the Hahn-Banach Theorem:  If $V$ is a normed vector space with linear subspace $U$ (not necessarily closed) and if $z$ is an element of $V$ not in the closure of $U$, then there exists a continuous linear map $ψ : V → K$ with $ψ(x) = 0$ for all $x$ in $U$, $ψ(z) = 1$, and $||ψ|| = dist(z, U)^{−1}.$  How is this a consequence of the Hahn-Banach Theorem? Axiom of Choice: Where does my argument for proving the axiom of choice fail? Help me understand why this is an axiom, and not a theorem. In terms of purely set theory, the axiom of choice says that for any set $A$, its power set (with empty set removed) has a choice function, i.e. there exists a function $f\colon \mathcal{P}^*(A)\rightarrow A$ such that for any subset $S$ of $A$, $f(S)\in S.$ Is this correct?  My question then is about proving this fact, so that we do not need to put it as an axiom. Now as per the research done on this single object- Axiom of Choice, I believe here that there should be some falsity in my argument. I do not find the mistake.  For any $S\in \mathcal{P}^*(A)$, since $S\neq \emptyset$, $\exists s\in S$. Define $f(S)=s$. Then $f$ is a choice function.  This was showing me that the axiom of choice is proved, but then why it had been put as an axiom? For example, in  book, the author asserts that      It is a metatheorem of mathematical logic that it is impossible to specify the function that assigns to each non-empty subset of $\mathbb{R}$, an element of itself.     There are several notes and books on axiom of choice, but here I am trying to understand through doing some argument for some problem, where problem actually arises. Rename profile folder on Windows 7/8 In the early '80s, I read a story about a Terran man on another planet, where the natives develop skin lesions and eventually die, but are happy, as they become part of the planet they live on. I remember that the protagonist is not developing the lesions, because he hates the planet. Once he starts loving the planet, he starts having the lesions as well. In this story, the planet is "alive".  I have read about "" and "". They do not match my memory. Thank you. Is it possible to spawn mobs in random places? I installed Windows on my computer, followed by an installation of Ubuntu. However, now I'm unable to boot into my Windows install.  What can I do to fix this? Concecutive last zeroes in expansion of $100!$ I have some questions with string theory:   Why is it that there is exactly 4 large spacetime dimensions while the rest remain small? It is a nonlocal QFT. How could that fit in GR? What are bitwise operators? I would like to work out the Fourier transform of the Gaussian function   $$f(x) = \exp \left(-n^2(x-m)^2 \right)$$  It seems likely that I will need to use differentiation and the shift rule at some point, but I can't seem to get the calculation to work. Does anyone have any advice?  By the way, I am using   $$\mbox{FT}(f)(k)=\int_{-\infty}^\infty f(x)e^{-ikx}\,\mathrm d x$$  as my definition of a Fourier transform. Many thanks. Comprehensive list of tools that simplify the generation of LaTeX tables Manually hacking tables in LaTeX is one of the less funny things when preparing a document. Naturally, there are quite a few tools that promise to simplify this. In fact, I have somewhat lost track of all the tools available, and I'd like to gather your valuable experience into one big post. Some of the tools are mentioned in , but I feel there's much more around.  I'd suggest that somebody starts an overview with an alphabetic list (so that I can accept this answer and it stays on top), and that everyone replies with a "community wiki" entry, one reply per tool, and inserts the tool into the list.  Personally, I use Excel2LaTeX, but I'm unhappy with having to fire up Windows in order to generate the LaTeX code. I'm thinking of a rewrite as a standalone Python tool using the xlrd library, but I'm not too inclined to reinvent the wheel. What are the most suitable filter holders for my Samyang 14mm autofocus prime lens? I've looked into the ones from Haida and Nisi which are both suitable, though they're quite pricey for me currently - does anybody know of any cheaper possible alternatives? I understand there's the 160mm specifically made for use with this lens, though obtaining filters for it is difficult and limited. I'm hoping for something which may be cheaper than both Haida and Nisi, and still suitable for the 14mm lens. Thanks! Right now, I have everything in a partition (except EFI system partition). How can I split the partition into two, one for / and one for /home?   How would you use parted to do that step by step?  How would you use gparted to do that step by step?  How would you use LVM to do that step by step?   One thing I am not sure of is that I can't just shrink the partition and create a second partition on the space that is freed by shrinking, because that doesn't move /home to the new partition.  Thanks.    $ sudo parted -l [sudo] password for t:  Model: ATA TOSHIBA MQ01ABF0 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:   Number  Start   End    Size   File system  Name                  Flags  1      1049kB  538MB  537MB  fat32        EFI System Partition  boot, esp  2      538MB   500GB  500GB  ext4  $ sudo df -h [sudo] password for t:  Filesystem      Size  Used Avail Use% Mounted on udev            1.7G     0  1.7G   0% /dev tmpfs           340M  1.4M  338M   1% /run /dev/sda2       457G  6.7G  428G   2% / tmpfs           1.7G   27M  1.7G   2% /dev/shm tmpfs           5.0M  4.0K  5.0M   1% /run/lock tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup /dev/sda1       511M  6.1M  505M   2% /boot/efi tmpfs           340M   20K  340M   1% /run/user/1000 tmpfs           340M     0  340M   0% /run/user/106 Why three-phase power? Why not a higher number of phases? Is there a reason, beyond historical reasons, that three phases has become the dominant number of phases?  I am aware of the advantages against one phase and two phase, namely the reduced amount of conductor needed, and that motors can provide torque when stalled (and less pulsation).  Is this solely due to diminishing returns, with only a small increase in smoothness of torque application, at the cost of increased complexity (increased number of wires (albeit of smaller CSA)).  To be clear, the phases are all evenly distributed, that is, five phases separated by 72 degrees.