Initially I have shuffled the array elements, how do I sort these elements?
How do I sort an NSMutableArray with custom objects in it?
Why did the limit of power change from wizard/witch to wand? So in the first 5 or 6 books, it was very clear that the wand chooses the wizard and the power/level of the spells the wizard produces is based on the knowledge and skill of the wizard.  This is referenced by people constantly being telling Harry that he wasn't skilled enough to perform certain spells, or Bellatrix telling Harry that he needed to mean the Cruciatus curse for it to be effective.  However, in the 7th book, this entire idea is changed to the wand being the thing that's powerful and regardless of the wizard's/witch's skill or knowledge, he/she could still perform a very advanced spell if it's something the wand could handle.  Goyle accidentally creating a fire serpent is something that instantly comes to mind from the movies(I don't remember if that happened in the book).  So, my question is, what actually holds the power, the wizard/witch, or the wand? Almost all passports I have seen have a place of birth field on them. For instance, on the US Passport,    Is there a specific reason to this? How did Gandalf elude and puzzle Sauron? In the History of Middle-Earth book collection Myths Transformed we learn a lot about how Sauron perceived the Istari and what he knew of them.     Sauron had, in fact been very like Saruman, and so understood him quickly and could guess what he would be likely to think and do, even without the aid of the palantiri or of spies; whereas Gandalf eluded and puzzled him.   (Home X: Myths Transformed)     Gandalf he did not understand. But certainly he had already become evil, and therefore stupid, enough to imagine that his different behaviour was due simply to weaker intelligence and lack of firm masterful purpose. He was only rather a cleverer Radagast &mdash; cleverer, because it is more profitable (more productive of power) to become absorbed in the study of people than of animals.   (ibid)  My question now is how does Gandalf elude and puzzle Sauron so much? We know he found Saruman simple to guess down to having similar minds (maybe down to both being maia of Aule?), we also know he must know a fair bit of Radagast as he refers to Gandalf as merely a smarter version of Radagast who was known to have abandoned his task which the Istari were given.   While Sauron went face to face with Saruman via the palantir, it is surprising that he finds Gandalf basically strange, even though Gandalf in reality does the most to circumvent Sauron out of the Istari in the north-west.   Gandalf enters Dol Guldur which Sauron flees. Gandalf enters Dol Guldur again in secret and claims he only just escaped with his life,  which suggests Sauron may have ended up noticing him. Gandalf pushes White Council to attack Dol Guldur which Sauron foresees. Gandalf fought with all nine of Sauron's greatest servants at Weathertop and played a part in destroying their physical bodies temporarily. Gandalf leads the Fellowship from Rivendell, which Sauron also knows. Gandalf strives with the Dark Tower when Frodo puts the ring on at Amon Hen. Gandalf is present at the Battle of the Black Gate, in which the mouth of Sauron declares they know all about Gandalf.   As I've pointed out, Gandalf is clearly sent to contest Sauron. But I don't understand why Sauron does not see this; throughout the Third Age, well, since the coming of the Istari Gandalf has played a role in almost every contest against Sauron.  So how did he elude and puzzle him? Are C++ enums signed or unsigned? And by extension is it safe to validate an input by checking that it is &lt;= your max value, and leave out >= your min value (assuming you started at 0 and incremented by 1)? Forecast total for a year given monthly time series I have a monthly time series (for 2009-2012 non-stationary, with seasonality). I can use ARIMA (or ETS) to obtain point and interval forecasts for each month of 2013, but I am interested in forecasting the total for the whole year, including prediction intervals. Is there an easy way in R to obtain interval forecasts for the total for 2013? How to draw a torus Is there an easy way to draw a contour image of torus below with tikz? Or for that matter with any other graphics package. Order of a group and subsequent subgroups I want to prove that if the order of a group G is greater than 1 and non-prime, then G has a subgroup other than the trivial subgroups {e} and G itself.   I am confused because I am only being able to prove the case for prime order by using Lagrange’s theorem i.e. if I have a group of order p, where p is a prime number, then the order of subgroups must divide p, hence the order can be either 1 or p.   How do I go about proving the case for non prime order let’s say x > 1? Pretty printing XML with javascript I have a string that represents a non indented XML that I would like to pretty-print. For example:  &lt;root&gt;&lt;node/&gt;&lt;/root&gt;   should become:  &lt;root&gt;   &lt;node/&gt; &lt;/root&gt;   Syntax highlighting is not a requirement. To tackle the problem I first transform the XML to add carriage returns and white spaces and then use a  tag to output the XML. To add new lines and white spaces I wrote the following function:   function formatXml(xml) {     var formatted = '';     var reg = /(&gt;)(&lt;)(\/*)/g;     xml = xml.replace(reg, '$1\r\n$2$3');     var pad = 0;     jQuery.each(xml.split('\r\n'), function(index, node) {         var indent = 0;         if (node.match( /.+&lt;\/\w[^&gt;]*&gt;$/ )) {             indent = 0;         } else if (node.match( /^&lt;\/\w/ )) {             if (pad != 0) {                 pad -= 1;             }         } else if (node.match( /^&lt;\w[^&gt;]*[^\/]&gt;.*$/ )) {             indent = 1;         } else {             indent = 0;         }          var padding = '';         for (var i = 0; i &lt; pad; i++) {             padding += '  ';         }          formatted += padding + node + '\r\n';         pad += indent;     });      return formatted; }   I then call the function like this:  jQuery('pre.formatted-xml').text(formatXml('&lt;root&gt;&lt;node1/&gt;&lt;/root&gt;'));   This works perfectly fine for me but while I was writing the previous function I thought that there must be a better way. So my question is do you know of any better way given an XML string to pretty-print it in an html page? Any javascript frameworks and/or plugins that could do the job are welcome. My only requirement is this to be done on the client side. It is quite easy to show that for every prime $p$ and $0&lt;i&lt;p$ we have that $p$ divides the binomial coefficient $\large p\choose i$; one simply notes that in $\large \frac{p!}{i!(p-i)!}$ the numerator is divisible by $p$ whereas the denominator is not (since it is a product of numbers smaller than $p$ and $p$ is prime).  My problem is with generalizing this argument for $q=p^n$. I'm looking for the most elegant and simple way to prove that $p$ still divides $\large q\choose i$. Prove or disprove: if $\sum\limits_{n=0}^∞a_n$ converges and $\lim\limits_{n\to\infty}b_n =0$, then $\sum\limits_{n=0}^{\infty}a_n b_n$ converges. Windows 10 - disable reopening programs after restart/startup Occasionally, a forced restart is happening on my Windows 10 computer. When the OS is restarted every program that I've had prior to the restart is reopened at startup. The programs are reopened like I would just double-click them.  I usually hold 5-6 windows of Visual Studio and few more programs all together. When the above happens, I have to wait several minutes until I can start working, as everything takes ages to load.  Is there a setting to disable these programs from automatically opening at startup? List View Visibility Removing nodes from graphs such that one is dependent on other - ZIO $2010$, P$1$ Greetings Community! The above problem you see is a combinatorics problem I could not solve. :( This problem is from ZIO $2010$, P$1$.     Here is what I did: Observe that every graph can be divided into "sub-groups" which may help in solving. We first remove the empty set. Then the singleton set. Consider the bigger but smaller than the sub-parts example:    The singleton sets are $\{4,5,6\}$ which are at the least position in the graph.   The dual sets are $\{2,4\}, \{3,5\}, \{3,6\}$, the bottom - two portions in the graph. The triplet sets are $\{2,4,5\}, \{4,5,6\}$ which we may manually count but for the bigger graphs in the sub-part, this may prove to be difficult and this is where I am stuck.   Any help would be appreciated. Thanks. Say we have the following sample and we are trying to estimate the variance of the sample mean of the population.  X = [0, -1, 2, 10, -3]   If I take an increasing number of bootstrap (e.g. 100, 1000, 10,000, 100,0000), the bootstrap distribution of the sample mean gets narrower and narrower. In other words, I can make the bootstrap distribution arbitrarily narrow.   Given the above, what's the point of using a different number of bootstrap samples here? And wouldn't this mean that I could make the standard error of the mean arbitrarily small by just taking more and more bootstrap samples? What am I missing?  Please note that I am doing a proper bootstrap sample in the sense that each bootstrap sample has the same exact size as the original sample (input array). How do volume control headphones work? A recent question over on  got me to wondering how volume control headphones work.  I don't mean volume control which works by , but the kind of volume control that signals to the device to increase or decrease the signal output.  For instance, according to the , the volume controls are only for apple devices:     Universal Compatibility and Microphone Communication   LP comes with 2 cables for universal compatibility with all modern mobile and audio devices. The 3-Button remote microphone cable is designed for the latest Apple devices, including iPhone®,iPad®, iPod®, and Macbook series. The long audio-only cable and 1/4" adapter is universally compatible with all audio devices and professional equipment.   However this sort of device apparently works with some android phones and the question implies that it works with some computer sound cards on Windows machines too, but not being an Apple buyer (and only recently getting my first smartphone) I haven't seen this sort of thing before. I've done a quick google search, but can't find anything on standards for this technology.   How does this work?   Is it something as simple as shorting left/right/mic channels? If so, could using headphones of this type with equipment that doesn't support this technology, damage that equipment? Is it a serial signal, for instance sent over the mic channel? Does it just require a headphone  connector or a headphone  +microphone TRRS connector?   Does this technique have a name?  Incidentally, is someone could answer this, I can probably look up the rest of the information myself. *8') Is it as standard as it appears, or is everyone just following Apple? Is this something that is patented?   If so, who holds the patent and do they charge a license fee for people to use this technology? If not, is there an open standard for it?    There is some excellent information in  to the question  but it doesn't answer the specifics of how this type of volume (etc.) control works, since it now seems to be rather more common and standard. How to find users by name Let $V$ be spherically symmetric and $W$ i.i.d. Gaussian. Then $E[V|V+W=t]=g(\|t\|)$ A random vector $V \in \mathbb{R}^n$ is said to be spherically symmetric. If for every orthogonal matrix  $A$   the distribution of $AV$ is the same as the distribution of $V$.   My question: Let $W$ be  i.i.d. zero mean Gaussian random variable.     Can we show that  for a spherically symmetric $V$ the conditional expectation  \begin{align} E[V|V+W=t]=   g(\|t\|).  \end{align}  That is the conditional expectation is only a function of the magnitude.   My attempt:  \begin{align} E[V|V+W=t]= \int  V  \frac{f_W(t-v)}{f_{V+W}(t)} dP_V(v)= \frac{\int  v  f_W(t-v) dP_V(v)}{f_{V+W}(t)}= \frac{E[ V  f_W(t-V) ]}{f_{V+W}(t)} \end{align}  Therefore, we can show that the two functions in the above ratio only depend on $\|t\|$.   Observe that we can write $t= \|t\| u_t$  where $u_t$ is a unit vector. Then, for any orthogonal matrix $A$ \begin{align} f_{V+W}(t)=f_{V+W}(\|t\|, u_t)&amp;= \frac{1}{(2\pi)^{n/2}} E[ e^{-\frac{\|t-V  \|^2}{2}} ]\\ &amp;= \frac{1}{(2\pi)^{n/2}} E[ e^{-\frac{\|t-AV  \|^2}{2}} ]\\ &amp;= \frac{1}{(2\pi)^{n/2}} E[ e^{-\frac{\|tA^{-1}-V  \|^2}{2}} ]\\ &amp;= \frac{1}{(2\pi)^{n/2}} E[ e^{-\frac{\|t A^T-V  \|^2}{2}} ]\\ &amp;= f_{V+W}(tA^T)\\ &amp;= f_{V+W}(\|t\|,  u_t A^T) \end{align}  Since, $A$ was arbitrary  we have that $f_{V+W}(t)=h(\|t\|)$(i.e., only depends on the magnitute).  Now I am not sure how to show that $E[ V  f_W(t-V) ]$ only depends on $\|t\|$? Triangle inequality for L2 norm I am posed with a problem as below.  Let $X$ be the collection of real valued functions that are measurable on $[0,1]$. For a given number $p\geq 1$ define the $L^p$ norm by $(\int_0^1|f(x)|^p)^\frac{1}{p}$.  I need to show for $p=1,2$ that this defines a semi norm on $X$. $p=1$ was simple as was all of $p=2$ except for the triangle inequality. I am having trouble proving the triangle inequality for this. Could anybody nudge me into the right direction or am I simply over thinking it? I think I can prove it for vectors but I'm not sure how to tackle it with integrals. Right now I can only use relatively basic results because this in for an introductory measure theory course.  Thanks! In ArcMap, when you export data to PDF it preserves the layering within the PDF so that you can turn on/off individual map layers (within the PDF itself).  When I export from QGIS to PDF, I don't appear to have the option for this.  Does QGIS support preserving layers when exporting to PDF?  Is there a special setting needed to enable this capability?  Or has anyone wrote a plugin for this feature? jQuery Validate Plugin - How to create a simple custom rule? How do you create a simple, custom rule using the jQuery Validate plugin (using ) that doesn't use a regex?  For example, what function would create a rule that validates only if at least one of a group of checkboxes is checked?