Posted in Codeigniter MySQL

Sort MySQL Table Data in Ascending or Descending Order in CodeIgniter 4

In this tutorial I am going to show you how to sort MySQL table data in ascending or descending order to display them on HTML table on user interface (UI) using Codeigniter 4. I had also shown similar example using CodeIgniter 3. So when a user wants to see the data on UI either in ascending or descending order then…

Continue Reading... Sort MySQL Table Data in Ascending or Descending Order in CodeIgniter 4
Posted in Array C Data Structure Sort Algorithm

Quick Sort using C

Introduction Quick sort or quicksort (sometimes called partition-exchange sort) is an efficient and very fast sorting algorithm for internal sorting, serving as a systematic method for placing the elements of an array in order. When implemented well, it can be about two or three times faster than its main competitors, merge sort and heapsort. In efficient implementations it is not…

Continue Reading... Quick Sort using C
Posted in Array C Data Structure Sort Algorithm

Bubble Sort using C

Introduction Bubble sort is one of the most popular sorting methods. It can be treated as a selection sort because it is based on successively selecting the smallest element, second smallest element and so on. In order to find the successive smallest elements this process relies heavily on the exchange of the adjacent elements and swaps them if they are…

Continue Reading... Bubble Sort using C
Posted in Array C Data Structure Sort Algorithm

Straight Selection Sort using C

Selection sorting refers to a class of algorithms for sorting a list of items using comparisons. These algorithms select successively smaller or larger items from the list and add them to the output sequence. This is an improvement of the Simple Selection Sort and it is called Straight Selection Sort. Therefore, instead of replacing the selected element by a unique…

Continue Reading... Straight Selection Sort using C
Posted in Array C Data Structure Sort Algorithm

Simple Selection Sort using C

The simplest possible technique based on the principle of repeated selection makes use of “n” passes over an array elements. In the i-th pass, the i-th smallest element is selected from the given array and it is placed in the i-th position of a separate output array. The already selected element is not selected next time and in order to…

Continue Reading... Simple Selection Sort using C
Posted in Array C Data Structure Sort Algorithm

Shell Sort using C

I will show here an example on shell sort (invented by Donald Shell) using C programming language. This method makes repeated use of straight insertion or shuttle sort. The method starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. An array with n elements, in each pass, an…

Continue Reading... Shell Sort using C
Posted in Array C Data Structure Sort Algorithm

Straight Insertion Sort using C

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. More details can be found here at https://en.wikipedia.org/wiki/Insertion_sort Let’s say we have an array a, so at each i-th pass, a[i] is successively compared with a[i-1], a[i-2], etc. until an element smaller than a[i] is found or the beginning of…

Continue Reading... Straight Insertion Sort using C
Posted in Array C Data Structure Sort Algorithm

Shuttle Sort using C

In Shuttle Sort technique for n elements in an array a, it requires n-1 passes. When i-th pass(1<=i<=n) begins, the first i elements, i.e., elements a[0] to a[i-1] have been sorted and these occupy the first i positions of the array. To insert (i+1)th element, a[i] is compared with a[i-1] and if the value of a[i] is smaller than a[i-1]…

Continue Reading... Shuttle Sort using C
Posted in PHP

PHP asort() example

This tutorial shows an example how to sort an array using asort() function available in PHP. The asort() function sorts an array by maintaining the index association. This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order…

Continue Reading... PHP asort() example
Posted in PHP

PHP natsort() example

This tutorial shows an example how to sort an array using natsort() function available in PHP. The natsort() function sorts an array using natural order sorting algorithm. This function implements a sorting algorithm that orders alphanumeric strings in the way a human being would read while maintaining key/value associations.

Continue Reading... PHP natsort() example