Boolean order statistic Inspired from this LeetCode question. I authored this question myself however. Please review my answer for accuracy.
Let's sort an array ($n \ge 1$) of $1$s and $0$s, so that all $0$s come before $1$s. At index $1 \le i \le n$, what's the probability that it will be a $1$? Assume identical and independent distribution.
More precisely:
Suppose that integer $\{0,1\}$ random variables $X_1,X_2,X_3,\dots,X_n$ are independently and identically distributed according to the Bernoulli distribution with a common probability $0 < p \le 1$.
Describe the distribution of each $X_{(i)}$, where $X_{(i)}$ is the $i$-th order statistic of $X$.
My Attempt
That $X_{(i)} = 0$ means that the first "$1$" may only occur at a trial numbered after $i$, if it ever occurs. When it does, we say that at trial $j$ the first "$1$" occurs.
Paraphrasing the first statement, I can say that that $X_{(i)} = 0$ and that $j > i$ are logically equivalent.
Let's model $j$, which represents the serial number of the trial for the first "$1$" outcome, with a helper random variable $J$. Specifically, we make $j$ an outcome of $J$.
The random variable $J$ has a CMF of
$$
P(J\le j) = 1 - (1 - p)^{j+1}
$$
So, the probability that $J > i$ is:
$$
P(J > i) = 1 - P(J \le i) = (1 - p)^{i + 1}
$$
Since $X_{(i)}$ is either "$0$" or "$1$," $X_{(i)}$ has a Bernoulli distribution with probability $1 - (1 - p)^{i+1}$.
Updated Answer
Thanks to both people who answered my question. I ran a simulation today and Ben's answer is correct, and my answer is not. To help me remember, let me paraphrase his answer:
The distribution of $X_{(i)}$ has to do with the number count of "$1$" outcomes, which is a related random variable. Specifically, the $i$-th item in the sorted sequence ($n \ge 1$) will be a "$1$" exactly when there are enough "$1$" outcomes.
In other words,

*

*The number of "$1$" outcomes—let's call $S$— is a random variable, represents the number of "successes" after $n$ trials with the probability $p$ each (IID). So, $S \sim \mathrm{Bin}(n,p)$.

*And, $n-S$ is the number of "$0$" outcomes. What's not a $1$ must be a $0$, and vice versa.

*The sorted item $X_{(i)} = 0$ if and only if $i \ge n - S$. Surely, there must be enough $0$s.

*Likewise, that "$X_{(i)} = 1$" and that "$i < n - S$" are logically equivalent.

The last sentence is particularly useful since it equates the probabilities $P(X_{(i)} = 1)$ and $P(S > n - i)$. The latter can be found by summing up the Binomial PMF.
Specifically,
$$
P(X_{(i)} = 1) = P(S \ge n - i + 1) = \sum_{k=n-i+1}^n f(k; n, p)
$$
where
$$
f(k; n, p) = {n \choose k} p^k (1-p)^{n-k}
$$
is the Binomial ($n,p$) PMF.
Simulation
Godbolt: https://godbolt.org/z/3PTW11rP3
extern crate anyhow;
extern crate rand;

use anyhow::{Context, Result};
use rand::distributions::{Bernoulli, Distribution};

pub fn main() -> Result<()> {
    let m = 10_000;
    let n = 5;
    let p = 0.37;

    eprintln!("{m} trials; array has {n} elements, probability {p}");

    let mut r = rand::thread_rng();
    let b = Bernoulli::new(p).context("Bernoulli impossible with given probability")?;

    let mut freq = vec![0; n];
    let mut samp = vec![0; n];

    for _ in 0..m {
        for (s, z) in samp.iter_mut().zip(b.sample_iter(&mut r)) {
            *s = z as i32;
        }
        samp.sort_unstable();
        for (f, s) in freq.iter_mut().zip(&samp) {
            *f += s;
        }
    }

    // Print in CSV
    println!("i,freq");
    for (i, f) in freq.iter().enumerate() {
        println!("{}, {f}", i + 1);
    }

    Ok(())
}

It prints the frequencies of position i being a $1$.
Example output:
10000 trials; array has 5 elements, probability 0.37
i,freq
1,64
2,652
3,2748
4,6215
5,9051

Grows as predicted by Ben.


Your analysis is not correct, since the values are no longer IID with fixed probability after they are sorted.
To facilitate analysis of this problem, denote the sum of the values as $S_n \equiv \sum_{i=1}^n X_i$ and note that this is equivalent to the number of ones.  Now, given that the binary values are IID with a fixed probability of being one, you have $S_n \sim \text{Bin}(n,p)$, so the sorted vector is:
$$(X_{(1)},...,X_{(n)}) = (\underbrace{0,...,0}_{n-S_n \text{ times}}, \underbrace{1,...,1}_{S_n \text{ times}}).$$
Consequently, for any element in the sorted vector (i.e., any of the order statistics) you have $X_{(i)} \sim \text{Bin}(\theta_i)$, where the probability parameter is:
$$\begin{align}
\theta_i \equiv \mathbb{P}(X_{(i)} = 1) 
&= \mathbb{P}(n-S_n < i) \\[12pt]
&= \mathbb{P}(S_n > n-i) \\[6pt]
&= \sum_{k=n-i+1}^n \text{Bin}(k|n,p). \\[6pt]
\end{align}$$
