random mallard tests [Wed, 26 Nov 2014 16:43:26 +0000]
Yesterday, I posted this post [http://blog.humaneguitarist.org/2014/11/25/a-quackish-approach-to-sorting-federerated-search-results/] about a method of sorting I'd been thinking about for a while. I also posted what I think is a solution in terms of an algorithm and a Python implementation. Not having real data to play with, I thought I'd try some random tests. So, here's the Python code below for getting random results and the output from running the random results generator a few times. In the output, I had results from the "b" list print out with an indentation to make it easier to see that while the results are intermixed, the original ordering per the "a" and "b" sets stays intact. Yeah, I know nobody cares about any of this except me, but this blog is largely a self-reference library for myself. Python:
from duck_sort import duck_sort
## auto-add tuple of data and random scores to list.
def make_rand(array, array_name):
limit = random.randrange(1,10)
for i in range(1,limit):
name = str(array_name) + str(i)
md = (name, random.randint(0,100))
## fill lists with random data, output results.
a = 
b = 
## use duck_sort() on random data; print results.
for result in duck_sort(a,b):
tab = ""
if result == "b": # for reading ease.
tab = "\t"
print tab + str(result)