Introduction#
Recently, I have become more interested in the fundamentals of computer science so I can become a better programmer and engineer.
Today we will create a simple sorting Function that will take two arrays as input, write each incoming request to Azure Table Storage and return the sorted array as well as some statistics on how long the Function ran.
Today’s example uses the WeightedQuickUnionWithPathCompression algorithm from Robert Sedgewick’s Algorithms in Java, Third Edition. He and Kevin Wayne have published a fourth edition which you can read online. If you’re interested in going further they offer their course free of charge on Coursera.
Prerequisites#
- Today’s demo assumes your Function is set up as a class library. Source code: AzureFunctionsBlogDemos.
Adding the Function#
We add a WeightedQuickUnionWithPathCompression class that parses an HTTP request containing two arrays, runs the merge algorithm, writes the result to Azure Table Storage, and returns the sorted output with runtime statistics.
The function.json binds an HTTP trigger for input and Azure Table Storage for output. The Arrays.cs shared class contains multiple merge algorithms (QuickFind, QuickUnion, WeightedQuickUnion, WeightedQuickUnionWithPathCompression) that we’ll compare in future posts.
Run and Test#
Hit F5, grab the URL, and use Postman to send a POST with two arrays of integers. The function merges them, writes to Table Storage, and returns the result with runtime.



Using Azure Storage Explorer, you can inspect the “Sorting” table to see inputs, outputs, and runtimes.


Conclusion#
Today we added a new Function that takes two arrays as input and merges them. We’ve taken advantage of our continuous deployment and can see every request written to Azure Table Storage with performance data.
What’s next:#
- Merge Algorithm Runtime Comparison series — comparing QuickFind, QuickUnion, WeightedQuickUnion and WeightedQuickUnionWithPathCompression using Azure ServiceBus Topics.
