Product sorting bug and data algorithms, a love story
This post is part of series on the test IO blog about real bugs that our testers have found during test cycles. In each post, we explore the details of the issue, explain its impact, and discuss what software teams can do to avoid similar problems.
The convenience of being able to sort through new arrivals, best match, top sellers, and pricing is the best thing to happen since cooked food. Having an algorithm do all the work for you with the click of a button is what makes online shopping fun. Who doesn’t love being able to skip past the product with 2.5 stars and move right to the 4-star reviews?
For our bug of the week we’ve decided to explore a price sorting bug that interfered with online product sorting that showed up in website testing for an ecommerce company.
While testing the product listing page of a mobile website, one of our testers discovered a price sorting bug. When the tester first loaded the product list to sort, “best match” was the default. When the tester switched the radio button to sort by price from low to high, the prices did not display in the correct order. The screen displayed a mix of unordered prices. The bug was initially discovered on an Android 5.1 device and could only be reproduced on mobile.
From this bug, we learn the importance of making sure there is a consistent algorithm behind the sort button.
It’s crucial to know the algorithms from a data structures point of view. This includes the characteristics of an algorithm, which you can learn more about in this article. There are many different types of sort algorithms, such as insertion sort, heapsort, mergesort, and quicksort. Insertion sort is widely used for small data sets. For large data sets heapsort, mergesort, and quicksort are often used. There’s also hybrid algorithms; timsort and introsort. Hybrid algorithms combine two or more other algorithms to solve the same problem. For example, Timsort combines merge and insertion sort and is often used in Android, Java and Python. Introsort combines quicksort and heapsort and is sometimes used in C++ sort implementations and in .NET.
If you told me in 1998 that I’d learn to love algorithms, I would not have believed you. From ecommerce to social media, sorting algorithms have changed the way we live.