Foot-Sorting for Socks

If your socks come out of the laundry all mixed up, how should you sort them? We introduce and study a novel foot-sorting algorithm that uses feet to attempt to sort a sock ordering; one can view this algorithm as an analogue of Knuth's stack-sorting algorithm for set partitions. The sock orderings that can be sorted using a fixed number of feet are characterized by Klazar's notion of set partition pattern containment. We give an enumeration involving Fibonacci numbers for the $1$-foot-sortable sock orderings within a naturally-arising class. We also prove that if you have socks of $n$ different colors, then you can always sort them using at most $\left\lceil\log_2(n)\right\rceil$ feet, and we use a Ramsey-theoretic argument to show that this bound is tight.


Introduction
1.1.How to sort your socks while standing on one foot.You have a lot of socks, and they are all arranged in a line.We call this a sock ordering.Unfortunately, the colors of the socks are all mixed up.You would like to fix this by sorting the socks into a line so that all socks of the same color are next to each other.Even more unfortunately, the only thing you know how to do with a sock is put it onto or take it off of your foot.For the moment, let us assume that you can put socks onto only one foot.Thus, you must use the following (non-deterministic) foot-sorting algorithm to try sorting your socks.
You begin by positioning yourself so that your unsorted line of socks is to your right.At each point in time, you can do one of the following operations: • Take the leftmost sock that lies to your right, and put it onto your foot, putting it over all other socks that are already on your foot.• Remove the outermost sock from your foot, and place it to your left, placing it to the right of all other socks to your left.
Figure 3 shows a real-life person using this algorithm to sort 7 socks.Let us say a sock ordering is sorted if all of the socks of each color appear consecutively.
A sock ordering is foot-sortable if it can be sorted (i.e., transformed into a sorted sock ordering) using this foot-sorting algorithm.We will consider two sock orderings to be the same if one is obtained from the other by renaming the colors.For example, and represent the same sock ordering.
1.2.Multiple feet.Most people have more than one foot; we can naturally generalize the footsorting algorithm to take advantage of this fact.Suppose you have t feet arranged in a line (you might need to borrow some friends' feet if t > 2).As before, position the feet so that the socks are to their right.Let us number the feet f 1 , . . ., f t from right to left.At each point in time, you can do one of the following operations: • Take the leftmost sock that lies to the right of the feet, and put it onto the foot f 1 .
• For some 1 ≤ i ≤ t − 1, remove the outermost sock from the foot f i , and put it on f i+1 .
• Remove the outermost sock from the foot f t , and place it to the left of the feet, placing it to the right of all other socks that are to the left of the feet.Let us say a sock ordering is t-foot-sortable if it can be sorted using this t-foot-sorting algorithm (see Figure 2).It is straightforward to verify that applying the t-foot-sorting algorithm is equivalent to applying the (ordinary) foot-sorting algorithm t times since one can use the spaces between adjacent feet as queues.

Set partitions.
A set partition of a set X is a collection {B 1 , . . ., B n } of nonempty pairwisedisjoint subsets of X such that n i=1 B i = X.The sets B 1 , . . ., B n are called the blocks of the partition.Throughout this article, we will always assume that X is a finite set of positive integers.
Suppose we have N socks, and let n be the total number of different sock colors.We consider socks of the same color to be identical, so we can view a sock ordering as a set partition of the set [N ] := {1, . . ., N } with n blocks: Two numbers i and j lie in the same block of the partition if and only if the socks in positions i and j have the same color.For example, the sock ordering corresponds to the set partition {{1, 3, 4}, {2, 6}, {5}}.By changing the names of the colors, we can also represent this set partition by abaacb (using the color set {a, b, c}) or 121132 or 131123 (using the color set {1, 2, 3}).In what follows, we will tacitly think of set partitions of [N ] and sock orderings of length N as the same objects, so it makes sense to discuss foot-sortable and, more generally, t-foot-sortable set partitions.
1.4.Sock patterns.Much research in combinatorics over the last few decades has focused on the notions of patterns and pattern avoidance for combinatorial objects.There is a natural notion of pattern containment and avoidance for sock orderings.We say the sock ordering ρ contains the sock ordering ρ ′ if ρ ′ can be obtained from ρ by deleting some socks.We say ρ avoids ρ ′ if ρ does not contain ρ ′ .For example, contains , while avoids .
Let us stress again that sock orderings are considered the same if they correspond to the same set partition.For instance, in the first example, we equally could have said that the sock ordering contains .
Under the correspondence between sock orderings and set partitions, our notions of containment and avoidance for sock patterns correspond precisely to a notion of containment and avoidance of set partitions that was introduced by Klazar [22,23] and investigated further in [2,6,9,21].
A sock ordering is sorted (equivalently, 0-foot-sortable) if and only if it avoids the pattern aba.More generally, for every fixed nonnegative integer t, the set of t-foot-sortable sock orderings is closed under containment.Indeed, suppose ρ is a t-foot-sortable sock ordering that contains the sock ordering ρ ′ .When we apply the t-foot-sorting algorithm to sort ρ, we perform a sequence of moves that put socks onto feet or remove socks from feet.The moves that involve the socks in ρ ′ will sort ρ ′ in the t-foot-sorting algorithm.1.5.Words and permutations.A word is a finite sequence of positive integers, possibly with repetitions.The standardization of a word w is the word obtained from w by replacing the i-th smallest number in w with i for all i.A word is standardized if it equals its standardization.For example, the standardization of 425446 is 213224, and the word 213224 is standardized.The numbers appearing in a word are called letters.A permutation is a word whose letters are all distinct.We write S n for the set of permutations that use the letters 1, 2, . . ., n.
Let v be a standardized word.We call v a pattern, and we say a word w contains v if there is a (not necessarily consecutive) subsequence of w whose standardization is v.For example, the word 356516 contains the pattern 231 because the standardization of the subsequence 351 is 231.We say w avoids v if it does not contain v.Note that this discussion also defines pattern containment and avoidance for permutations.For example, the permutation 534621 contains the pattern 231 because the standardization of the subsequence 341 is 231; on the other hand, 534621 avoids the pattern 132.
Given a word w of length N , there is a set partition ρ of [N ] in which each block is the set of positions at which a specific letter occurs in w; we say w represents the set partition (equivalently, sock ordering) ρ.However, different words can represent the same sock ordering; an example is given by the words 1312 and 2123, which both represent .1.6.Stack-sorting.There is long and rich line of research devoted to sorting procedures that use restricted data structures.One of the first instances of this topic appears in Knuth's book The Art of Computer Programming [24].Knuth discussed how to use a data structure called a stack to sort a permutation.One can push objects into the stack and pop objects out of the stack subject to the constraint that the object being popped out must be the object that was most recently pushed in (see Figure 3).This is exactly the same as how we can put socks onto a foot and remove socks from a foot subject to the constraint that the sock being removed from the foot must be the sock that was most recently put onto the foot.There are now several well-studied variants of Knuth's original stack-sorting algorithm, including pop-stack-sorting [4,5,29], deterministic (or West) stack-sorting [10,15,18,31], deterministic pop-stack-sorting [13,14,27], (deterministic) left-greedy stack-sorting [3,28], sorting with patternavoiding stacks [7,11,12,20], deterministic stack-sorting for words [19], generalizations to Coxeter groups [16,17], and so on.As far as we aware, no one has yet studied stack-sorting for set partitions (or socks, for that matter).

Main results.
A word is sorted if its letters appear in nondecreasing order.Note that there are non-sorted words (such as 2211) that represent sorted sock orderings.The only sorted permutation in S n is the identity permutation 123 • • • n.Knuth [24] characterized the permutations that can be sorted using a single stack via permutation patterns; they are precisely the permutations that avoid that pattern 231.In fact, this characterization was the original impetus for the now-enormous field of permutation patterns research.In general, the set of permutations that can be sorted by t stacks in series is closed under pattern containment, but when t ≥ 2, it is very difficult to characterize or enumerate such permutations.Indeed, only recently was it proven that one can decide in polynomial time whether or not a given permutation is 2-stack-sortable [26].As shown in Figure 3, one can also use a stack to sort words.As in the case of permutations, a word is stack-sortable if and only if it avoids 231 (the proof is identical to Knuth's proof in the permutation setting).The following theorem relates this fact to sock orderings.Theorem 1.1.A sock ordering ρ is foot-sortable if and only if there is a 231-avoiding word that represents ρ.
procedure in terms of socks and feet because we originally encountered this topic in a real-life attempt to sort socks using a stack (and also because it made the presentation cleaner).Only afterward did it occur to us that the stack should very naturally be replaced by a foot.(What you are reading is a literal footnote.) In this theorem, it is somewhat unsatisfactory that we have to look at all of the words representing a sock ordering in order to determine whether or not the sock ordering is foot-sortable; it would be more desirable to obtain a characterization purely in terms of set partition patterns.The latter problem appears to be quite difficult, in analogy with the problem of characterizing (or even enumerating) the 2-stack-sortable permutations.Although we cannot provide a complete patternavoidance characterization of the foot-sortable sock orderings, we can give a very precise description and enumeration when we restrict our attention to sock orderings of a special form.
Let us say a sock ordering is r-uniform if there are exactly r socks of each color.The 2-uniform sock orderings are especially natural examples of sock orderings because socks are often sold and worn in pairs.A set partition corresponding to a 2-uniform sock ordering is often called a matching.We say a 2-uniform sock ordering with 2n socks is alignment-free if the first n socks all have distinct colors.One can easily check that a 2-uniform sock ordering is alignment-free if and only if it avoids the pattern 2 .If ρ is an alignment-free 2-uniform sock ordering with 2n socks, then it can be represented by a unique word of the form 12 The map ρ → σ ρ is a bijection from the set of alignment-free 2-uniform sock orderings with 2n socks to S n .For example, the alignment-free 2-uniform sock ordering corresponds to the permutation 2431.
Our next theorem involves the sequence (F k ) k≥1 of Fibonacci numbers; our convention for indexing this sequence is that We remark that the permutations avoiding the patterns 123, 132, and 213 are precisely the reverses of the layered permutations in which each layer has size 1 or 2 (see Section 3).
Our last main result states that a person with n different colors of socks can always sort their socks using ⌈log 2 (n)⌉ feet and that this bound is tight.
Our proof of the first statement in the preceding theorem uses a simple inductive approach; it is completely analogous to an argument that Tarjan [30] gave to prove that every permutation of size n is ⌈log 2 (n)⌉-stack-sortable.On the other hand, our proof of the second statement is more delicate and requires a Ramsey-theoretic argument.
1.8.Outline.We prove Theorems 1.1 to 1.3 in Sections 2 to 4, respectively.In Section 5, we provide a laundry list of natural and intriguing open questions about foot-sorting. 2Our terminology comes from the fact that this pattern corresponds to the set partition {{1, 2}, {3, 4}}, which is often called an alignment.

Foot-Sorting and Stack-Sorting
This brief section is devoted to proving Theorem 1.1, which says that a sock ordering is footsortable if and only if there is a 231-avoiding permutation representing it.
Proof of Theorem 1.1.Let ρ be a sock ordering with n colors.Suppose first that there is a 231avoiding word w over the alphabet [n] that represents ρ.Then w is stack-sortable, so there is a sequence of moves that sends w through a stack to transform it into a sorted (i.e., nondecreasing) word.Each of these moves corresponds to a move in the foot-sorting algorithm.If we apply these moves to ρ, we will succeed in sorting ρ.
To prove the converse, suppose ρ is foot-sortable.Then there is a sorted sock ordering κ that can be obtained by applying the foot-sorting algorithm to ρ.Let v be the unique sorted word over the alphabet [n] that represents κ.Imagine "reversing time" and running the foot-sorting algorithm in reverse to transform κ into ρ.Each move in this "reversed foot-sorting algorithm" corresponds to a move in a "reversed stack-sorting algorithm," and applying these moves to v will result in a word w that represents ρ.Suppose there exist letters α < β < γ in v such that in the reversed stack-sorting algorithm, α leaves the stack before both β and γ.Then there is a point in time when α sits above β and β sits above γ in the stack, so β must leave the stack before γ.This means that these letters appear in the order γ, β, α in w.In particular, they can never appear in the order β, γ, α in w.This proves that w avoids 231.□

Alignment-Free 2-Uniform Sock Orderings
In this section, we prove Theorem 1.2, which characterizes and enumerates the foot-sortable alignment-free 2-uniform sock orderings.Say that an alignment-free 2-uniform sock ordering is spread-out if it satisfies one of the bullet-pointed conditions in the statement of Theorem 1.2.
The skew sum of two permutations σ ∈ S m and σ ′ ∈ S m ′ is the permutation σ ⊖ σ ′ ∈ S m+m ′ defined by Note that the skew sum is an associative operation.It is well known that a permutation avoids the patterns 123, 132, and 213 if and only if it is of the form where each ε i is either 1 or 12 [8,25].(Said differently, a permutation avoids 123, 132, and 213 if and only if it is the reverse of a layered permutation whose layers all have size 1 or 2.) It will be convenient to substitute this characterization into the bullet-pointed descriptions in the statement of Theorem 1.2.We will first show that foot-sortable alignment-free 2-uniform sock orderings are spread-out.Let ρ be a foot-sortable alignment-free 2-uniform sock ordering, and let σ ρ ∈ S n denote the corresponding permutation.There is nothing to show if n ≤ 2, so assume that n ≥ 3.For τ ∈ S n , write τ σ ρ for the product of τ and σ ρ in the symmetric group S n .Theorem 1.1 tells us that there exists τ ∈ S n such that the word w obtained by concatenating τ with τ σ ρ represents ρ and avoids the pattern 231.Note that the numbers 2, . . ., n appear in decreasing order in τ since otherwise we would find a 231 pattern in w.Hence, there is some 1 ≤ i ≤ n such that τ has the one-line notation and τ −1 has the one-line notation Since w avoids 231, we also see that τ σ ρ is a layered permutation whose layers all have size 1 or 2. Now we use the formula σ ρ = τ −1 (τ σ ρ ) to show that σ ρ has the desired form.We condition on the size of the first run in τ σ ρ .First, suppose that the first run in τ σ ρ has size 1.Then τ σ ρ (1) = 1, and σ ρ (1) = i.In this case, one easily verifies that the standardization of σ ρ (2) • • • σ ρ (n) is the skew sum of some number of increasing permutations of sizes 1 and 2; thus, regardless of whether or not σ ρ (1) = 1, we conclude that w satisfies one of the bullet-pointed conditions in the statement of Theorem 1.2 and hence is spread-out.Next, suppose that the first run in τ σ ρ has size 2. Then we have σ ρ (1) = τ −1 (2) = n and σ ρ (2) = τ −1 (1) = i, and (as in the previous case) the standardization of σ ρ (3) • • • σ ρ (n) is the skew sum of some number of increasing permutations of sizes 1 and 2. So w satisfies the second bullet-pointed condition in the statement of Theorem 1.2 and hence is spread-out.This completes the proof that foot-sortable alignment-free 2-uniform sock orderings are spread-out.
We will now show that spread-out sock orderings are foot-sortable.Let ρ be a spread-out sock ordering, and let σ ρ ∈ S n denote the corresponding permutation.First, suppose that σ ρ satisfies the first bullet-pointed condition in Theorem 1.2.Let i = σ ρ (1), and let τ ∈ S n be the permutation with the one-line notation The word obtained by concatenating τ with τ σ ρ represents ρ and avoids the pattern 231, so ρ is foot-sortable by Theorem 1.1.Next, suppose that σ ρ satisfies the second bullet-pointed condition in Theorem 1.2.Let i = σ ρ (2), and again let τ ∈ S n be the permutation with the one-line notation The word obtained by concatenating τ with τ σ ρ represents ρ and avoids the pattern 231, so ρ is foot-sortable by Theorem 1.1.This completes the proof of the first statement of Theorem 1.2; to prove the second statement, it remains to count the spread-out alignment-free 2-uniform sock orderings.
Let Av m (123, 132, 213) denote the set of permutations in S m that avoid the patterns 123, 132, 213.It is well known that |Av m (123, 132, 213)| is the Fibonacci number F m+1 .The permutations σ corresponding to the spread-out alignment-free 2-uniform sock orderings with n colors can be described as follows, according to the two bullet points in the statement of Theorem 1.2: • We can choose any element of (These patterns are the alignment-free 2-uniform sock orderings corresponding to the permutations 54123, 45123, 54132, 45132, 54213, 45213, 1234, 2314, 1243, 3124, 1324, 3142, 2134, 3214, 2143.)Using a computer (or some socks and a sufficient of patience), one can check that none of the sock orderings in this list are foot-sortable; note that this gives an alternative approach to the first half of the above proof of Theorem 1.2.

Logarithmically Many Feet
The goal of this section is to answer the following question: For a natural number n, what is the minimum value of t (depending on n) such that every sock ordering with n colors is t-foot-sortable?We will prove Theorem 1.3, which states that the answer is exactly ⌈log 2 (n)⌉.
Although the motivation for defining the t-foot-sorting algorithm is to sort a sock ordering, one can use it to permute the socks in other ways as well.For example, one could use the foot-sorting algorithm to transform into .
Given a sock ordering ρ, let foot(ρ) denote the set of sock orderings that can be obtained from ρ by applying the foot-sorting algorithm with a single foot, and let foot −1 (ρ) denote the set of sock orderings κ such that ρ ∈ foot(κ).We define foot 0 (ρ) = {ρ}.For t > 1, we inductively define foot t (ρ) = foot(foot t−1 (ρ)) and foot −t (ρ) = foot −1 (foot −t+1 (ρ)); it is a simple exercise to verify that foot t (ρ) is the set of sock orderings that can be obtained from ρ by applying the t-foot-sorting algorithm.
We can quickly prove the first statement in Theorem 1.3, which states that ⌈log 2 (n)⌉ feet always suffice to sort a sock ordering with n colors.This argument is very similar to one used by Tarjan in [30].Lemma 4.1.Every sock ordering with n colors is ⌈log 2 (n)⌉-foot-sortable.
Proof.It suffices to prove the theorem when n is a power of 2; say n = 2 k .We proceed by induction on k.The base case k = 0 is trivial since any sock ordering with a single color is already sorted.Now suppose k ≥ 1, and assume that all sock orderings with 2 k−1 colors are (k − 1)-foot-sortable.Let ρ be a sock ordering with 2 k colors.Partition the set of colors into two sets A, B, each of size 2 k−1 .Apply the foot-sorting algorithm once to ρ so that in the resulting sock ordering ρ ′ ∈ foot(ρ), all of the socks with colors from A appear to the left of all of the socks with colors from B. (For instance, sort according to the rules that every sock with color from A is removed from the foot immediately after being put on the foot and that no sock with color from B is removed from the foot until all socks with colors from A have been removed.)Write ρ ′ as a concatenation ρ ′ = κ A κ B , where κ A and κ B contain only socks with colors from A and from B, respectively.By the induction hypothesis, each of κ A and κ B can be sorted using k − 1 further applications of foot-sorting.Since these further applications can be run in parallel, we conclude that ρ is k-foot-sortable.□ It is much more difficult to show that some sock orderings with n colors require ⌈log 2 (n)⌉ feet to get sorted.To do so, we will study a particular class of sock orderings and show that they obey a Ramsey-theoretic property.Say that an r-uniform sock ordering with n colors is stratified if it is the concatenation of r chunks of size n, where each color appears once in each chunk.For example, the 2-uniform stratified sock orderings with 3 colors are , , , .
The following lemma says that if you apply the foot-sorting algorithm to a stratified sock ordering with n colors that has huge uniformity, then you are always guaranteed to find (as a pattern) a stratified sock ordering with ⌈n/2⌉ colors that has pretty big uniformity.
Lemma 4.2.Let n ≥ 2 and r be positive integers, and set r ′ = r 2 n ⌈n/2⌉ .If ρ is an r ′ -uniform stratified sock ordering with n colors, then every sock ordering in foot(ρ) contains an r-uniform stratified sock ordering with ⌈n/2⌉ colors as a pattern.
Proof.Set m = r ′ /r = r n ⌈n/2⌉ , and write ρ as a concatenation where each γ k has nr socks.(So each γ k is an r-uniform stratified sock ordering with n colors.)Imagine applying the foot-sorting algorithm to transform ρ into some sock ordering κ ∈ foot(ρ).
For each k ∈ [m], let X k be the set of socks in γ k that are removed from the foot before the last sock in γ k is put onto the foot.Let Y k be the set of distinct colors appearing in X k .We consider two cases.
Case 1. Suppose there exists k ∈ [m] such that |Y k | ≤ ⌊n/2⌋.Let Q be a subset of [n] \ Y k of size ⌈n/2⌉.At the moment when the last sock in γ k is put on the foot, the socks of γ k with colors in Q are all on the foot, and they appear in the same order (read from inside to outside) in which they appeared in ρ; note that these socks in ρ form a pattern that is an r-uniform stratified sock ordering with ⌈n/2⌉ colors.After the entire foot-sorting algorithm is complete, these same socks appear in κ in the opposite order from how they appeared in ρ.Since the reversal of a stratified sock ordering is still stratified, we have succeeded in finding the desired pattern in κ.
r such indices.For each k i , choose a subset A i ⊆ X k i of size ⌈n/2⌉ such that A i has one sock of each color in Q.The definition of X k 1 ensures that all of the socks in A 1 are removed from the foot before the last sock of γ k 1 is put on the foot.After this, but before the last sock of γ k 2 is put on the foot, all of the socks in A 2 are removed from the foot.Continuing in this fashion, we find a sock pattern in κ consisting of some permutation of the socks in A 1 , followed by some permutation of the socks in A 2 , and so on, up to some permutation of the socks in A r .But this is precisely an occurrence of an r-uniform stratified sock ordering with ⌈n/2⌉ colors, as desired.□ We are now ready to prove Theorem 1.3, which says that every sock ordering with n colors is ⌈log 2 (n)⌉-foot-sortable and that sometimes ⌈log 2 (n)⌉ feet are required.
Proof of Theorem 1.3.The first statement in Theorem 1.3 is Lemma 4.1.To prove the second statement, let r(2) = 2, and let r(n) = r(⌈n/2⌉) 2 n ⌈n/2⌉ for all n ≥ 3. We will prove that for every n ≥ 2, no r(n)-uniform stratified sock ordering with n colors is (⌈log 2 (n)⌉ − 1)-foot-sortable.This is easy when n = 2 because the two different 2-uniform stratified sock orderings with 2 colors are abab and abba, neither of which is sorted.We now assume n ≥ 3 and proceed by induction on n.
Let ρ be an r(n)-uniform stratified sock ordering with n colors.Our goal is to show that no sock ordering in foot(ρ) is (⌈log 2 (n)⌉ − 2)-foot-sortable.Choose any κ ∈ foot(ρ).According to Lemma 4.2, the sock ordering κ contains an r(⌈n/2⌉)-uniform stratified sock ordering η with ⌈n/2⌉ colors as a pattern.By induction, η is not (⌈log 2 (⌈n/2⌉)⌉ − 1)-foot-sortable.This implies that κ is also not (⌈log 2 (⌈n/2⌉)⌉ − 1)-foot-sortable, and the theorem now follows from the simple fact that ⌈log 2 (⌈n/2⌉)⌉ = ⌈log 2 (n)⌉ − 1. □ Remark 5.2.In the time since the original preprint of this article was released, Yu has resolved Question 5.1 by showing that both of the bases considered in that question are infinite [33].Yu has also provided a polynomial-time algorithm for deciding whether a given sock ordering is footsortable.
It would also be interesting to enumerate the 2-uniform foot-sortable sock orderings with n colors.Another line of investigation concerns bounds for "worst-case sorting," as studied in Section 4.
Question 5.3.What is the smallest integer t 2 (n) such that every 2-uniform sock ordering with n colors is t 2 (n)-foot-sortable?
Recall that, as discussed after the proof of Proposition 4.4, we have 1 2 log 4 (n) ≤ t 2 (n) ≤ ⌈log 2 (n)⌉ .Define r(n) to be the smallest integer such that there exists an r(n)-uniform sock ordering with n colors that is not (⌈log 2 (n)⌉ − 1)-foot-sortable.Theorem 1.3 states that r(n) is finite, and it follows from our proof of this theorem that r(n) ≤ n (1+o(1))n .This function remains mysterious, and it is not even obvious whether or not r(n) tends to infinity with n.Avis and Newborn [5] introduced a variant of Knuth's stack data structure called a pop-stack (see also [4,29]).A pop-stack is just like a stack, except it has the additional property that whenever an object is removed from the pop-stack, all objects must be removed.One could analogously consider sorting socks using pop-feet, which are just like feet except that whenever a sock is removed from a pop-foot, all socks must be removed from the pop-foot.It would be interesting to study t-pop-foot sortable sock orderings.
In the stack-sorting and pop-stack sorting literature, one can consider sorting permutations using stacks or pop-stacks that are arranged in series or in parallel (see [1,4,29]).Our t-footsorting algorithm uses t feet in series, but one could also consider what happens when the feet are arranged in parallel.In this setting, we imagine t feet arranged in a line as before.At each point in time, the leftmost sock lying to the right of the feet can be placed directly onto one of the feet (and any of the feet can be chosen), or a sock can be removed from one of the feet and put into the output sock ordering.It could be interesting to study which sock orderings can be sorted using t feet in parallel.One could also consider mixtures of feet and pop-feet in series and in parallel, as in [29].
Finally, we mention that Xia [32] has introduced deterministic versions of foot-sorting (in which stacks are used in place of feet).

Figure 1 .
Figure 1.Seven socks begin in the (unsorted) sock ordering BLACK YELLOW PEPPERMINT YELLOW BLACK PEPPERMINT.A real person uses the foot-sorting algorithm to sort these socks into YELLOW YELLOW PEPPERMINT PEPPERMINT BLACK BLACK.The pictures should be read row by row.

Figure 2 .
Figure 2. Three socks begin in the (unsorted) sock ordering YELLOW BLACK YELLOW.A real person uses the 2-foot-sorting algorithm to sort these socks.The pictures should be read row by row.

Figure 3 .
Figure 3. Using a stack to sort the word 1614.

Case 2 .
Suppose |Y k | ≥ ⌈n/2⌉ for every k ∈ [m].Since m = r n ⌈n/2⌉ , we can use the Pigeonhole Principle to find a subset Q of [n] of size ⌈n/2⌉ such that there are at least r indices