Sort arrays inside an array using a common key
How can I sort arrays and data in PHP?
If $f(x)=x-\int^{\frac{\pi}{2}}_0f(x)\sin(x)dx$ find the explicit function for $f(x)$ in its simplest form When to Garbage Collect CPU Emulation and locking to a specific clock speed If you had read my other , you'll know I've spent this weekend putting together a 6502 CPU emulator as a programming exercise.  The CPU emulator is mostly complete, and seems to be fairly accurate from my limited testing, however it is running incredibly fast, and I want to throttle it down to the actual clock speed of the machine.  My current test loop is this:      // Just loop infinitely.     while (1 == 1)     {                         CPU.ClockCyclesBeforeNext--;          if (CPU.ClockCyclesBeforeNext &lt;= 0)         {             // Find out how many clock cycles this instruction will take             CPU.ClockCyclesBeforeNext = CPU.OpcodeMapper.Map[CPU.Memory[CPU.PC]].CpuCycles;              // Run the instruction             CPU.ExecuteInstruction(CPU.Memory[CPU.PC]);              // Debugging Info             CPU.DumpDebug();             Console.WriteLine(CPU.OpcodeMapper.Map[CPU.Memory[CPU.PC]].ArgumentLength);              // Move to next instruction             CPU.PC += 1 + CPU.OpcodeMapper.Map[CPU.Memory[CPU.PC]].ArgumentLength;                                                 }     }   As you can tell, each opcode takes a specific amount of time to complete, so I do not run the next instruction until I count down the CPU Cycle clock. This provides proper timing between opcodes, its just that the entire thing runs way to fast.  The targeted CPU speed is 1.79mhz, however I'd like whatever solution to the clock issue to keep the speed at 1.79mhz even as I add complexity, so I don't have to adjust it up.  Any ideas? Show that the set of all polynomials whose constant term is a multiple of 3 is an ideal of the ring $Z[x]$.   Attempt: Suppose then we need to show   if $p(x), q(x) \in I$ then $p(x) + q(x) \in I$  and if $r(x) \in Z[x]$ , then $p(x)r(x) \in I$ and $r(x)p(x) \in I$.  And $0 \in Z$, then $0 \in I$.  Then let   $I =$ {$a_nx^n + a_{n-1}x^{n-1} + ...+a_1x + a_0$ | $a_i \in Z$, $a_0\in 3Z$}  $p(x)  = a_nx^n + a_{n-1}x^{n-1} + ...+a_1x + 3a$  and $q(x) = b_mx^n + b_{m-1}x^{n-1} + ...+b_1x + 3b$  Here we do not assume that $p(x) $ and $q(x)$ have the same degree.  Then $p(x) + q(x)  = [a_nx^n + a_{n-1}x^{n-1} + ...+a_1x + 3a]  +  [b_mx^n + b_{m-1}x^{n-1} + ...+b_1x + 3b] = 3(a + b) + (a_1 + b_1)x + ....+ (a_n + b_m)x^n$.  so $p(x) + q(x) \in I$  And $0 \in Z$ is also in $I$, since for $p(x) = 0x^n + ....+ 3(0) = 0$.  And let $r(x)= c_nx^n + ...+3c  \in Z[x] $.  Then $r(x)p(x) = 3(3ac) + (3b_1 + 3a_1) + ....+ a_nb_mx^{2n}$  So $r(x)p(x) \in I$.  Can someone please help? I am not really sure how to prove this. I am getting confused with the underscrips Any help or better approach would really help. Thanks in advance! $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ twice Does there exist a continuous function $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ exactly two times? Why is causality preserved in special relativity? PART 1: I was reading the article  Wikipedia. I couldn't understand this line:       "if the two events are causally connected ("event A causes event B"), the causal order is preserved (i.e., "event A precedes event B") in all frames of reference."     Is this an assumption or a consequence of STR? Please explain.       Note: My question consists of 2 parts this is the 2nd part. Below is a genral version of my previous question question:.   PART 2: Let there be three events $A$,$B$ and $C$ s.t: $C$ is the result of Simultaneous occurrence of $A$ and $B$. In other words $C$ occurs iff $A$ and $B$ are simultaneous. Now as we know in STR any two events separated in space are not simultaneous in different frames. So In some frames $C$ will occur and in some $C$ will not occur which will cause paradox. I tried many thought experiments to make such a paradox but i failed. In all the experiments that i thought i could not break the causality even by breaking the simultaneity because everytime the fact: "all signals move slower than light" preserved the causality.    So why causlity remains preserved always? Is it due to the fact that nothing can move faster than light? Area of a quadrilateral proof How do I resize my partition in Ubuntu? I had Windows 8 installed on my system, which I screwed up, and now I run Ubuntu 12.04. While installing, Ubuntu used all the 461 GB of HDD space (one partition).   Now I want to make a new partition of maybe 100 GB or so, in order to install Windows 7 alongside Ubuntu (with a dual-boot). But I can't even get a partition done. I can't change the partition in GParted either - the option is disabled. Laptop water damage repair procedure I'd love some advice in repairing a water-damaged laptop.  My girlfriend spilled a glass of water on her Sony Vaio and now it doesn't turn on...at all...dead! What steps should I go through to work out where the problem is and which part(s) I'll need to replace?  I can't seem to find out what has happened by just looking at the circuit boards. I'm new to electronics but could buy relevant volt-meters etc. I'm just looking for a decent trouble-shooting guide. I know that the gravitational interaction of antimatter is expected to be the same as normal matter.  But my question is, has it ever been experimentally validated?  I think it would not be a trivial experiment, because electromagnetic effects have to be eliminated, so neutral particles would be needed. Maybe diamagnetically trapped antihidrogen atoms could be examined as to which direction they fall? What does asterisk * mean in Python? Does * have a special meaning in Python as it does in C? I saw a function like this in the Python Cookbook:  def get(self, *a, **kw)   Would you please explain it to me or point out where I can find an answer (Google interprets the * as wild card character and thus I cannot find a satisfactory answer). Infinite partition of $\mathbb N$ by infinite subsets Alignment numbered apalike bibliography style I prefer the apalike bibliography style with the number in brackets in front (see also  and ). However what I am curious about is how to align the first and subsequent text lines neatly next to the number in brackets.    Does anyone know how to do this? Integrate $\int \frac{25 - x^2}{x^4} \operatorname d\!x$ I think we use trig substitution for this. But I'm not sure where to even begin with this   $$\int \frac{25 - x^2}{x^4} \operatorname d\!x$$ What's the best blog post/video/tweet/whatever to explain how the Stack Exchange system works to regular people? I am trying to gauge interest for a new Stack Exchange site, but I want to explain it to people as best (and preferably) as visually as I can. Any YouTube clips breaking it down?  anyone?  Note: I am fully aware of , but mine is about Stack Exchange, not Stack Overflow.  Most people think I'm describing traditional forum software, which they know sucks. Is there some way to describe the magic of how the design of the Stack Exchange system actually produces useful results very quickly? I can describe generally that it is a Q&amp;A site that users vote on the answers, but Stack Overflow feels like so much more. Am I perhaps thinking too big about this? Does $\sum\limits_{k=1}^n 1 / k ^ 2$ converge when $n\rightarrow\infty$? I can prove this sum has a constant upper bound like this: $$\sum_{k=1}^n \frac1{k ^ 2} \lt 1 + \sum_{k=2}^n \frac 1  {k (k - 1)} = 2 - \frac 1 n \lt 2$$ And computer calculation shows that sum seems to converge to 1.6449.  But I still want to know:  Does this sum converge? Is there a name of this sum (or the series $\frac{1}{k^2} $)? Why there isn't reputation points for successful flagging? By helping the site by flagging successfully (and therefore gaining higher flag weight), you typically inform that you are able to understand the system and be helpful.  Similarly, when you are helpful by editing posts (not necessarily even understanding anything, just making it better), you gain 2 points for each edit. Good flagging may require even more understanding; while editing just fixing spelling and/or formatting gives reputation points. You don't have to understand whether question (or answer) is on-topic, or even meaningful.  So, why there isn't for example 2 points for each flag that was acted on, in the same way flag weight increase is determined? I've encountered issues posting comments or answers numerous times over the last month, I've narrowed it down that it only occurs when I use UNION and ALL next to each other (ie SQL).  If I separate them by a dash it works fine. The error is always generic:  'An error occurred during ____ submission'  The blank being either comment or answer. Someone suggested I post this question here.  I do not see a similar question, interestingly even trying to search the site for UNION and ALL errored, similarly separating them with + returns an error. Screenshot:  This occurs in Chrome or IE, on Win 7, will test tonight from personal machines. UPDATE:  Apparently through good coincidence I just never had attempted to use UNION ALL when answering questions from home, works fine here.  So it must indeed be some firewall/policy setting at my office with very specific criteria, never found any other code bits I couldn't post, and don't have a problem with UNION ALL on other sites.  Still interested to find out how it's being blocked given our high level of access. What is the relation between electromagnetic wave and photon? British placement of punctuation relative to inverted commas