  In this paper we introduce the idea of partially sorting data to design
nonparametric tests. This approach gives rise to tests that are sensitive to
both the order and the underlying distribution of the data. We focus in
particular on a test that uses the bubble sort algorithm to partially sort the
data. We show that a function of the data, referred to as the empirical bubble
sort curve, converges uniformly to a limiting curve. We define a
goodness-of-fit test based on the distance between the empirical curve and its
limit. The asymptotic distribution of the test statistic is a generalization of
the Kolmogorov distribution. We apply the test in several examples and observe
that it outperforms classical nonparametric tests for appropriately chosen
sorting levels.
