# Sort

## What is a Sorting Algorithm? :rainbow:&#x20;

A **Sorting** Algorithm takes a disordered group and orders the group.

![Livraria Lello](/files/-MMbCXWSUxaMdakGh4TR)

## Insertion Sort :dollar: :yen: :euro: :pound:&#x20;

**Insertion Sort** is an algorithm which goes through a list item by item, putting each new item in the correct order.

**Insertion Sort:** &#x20;

1. Create a new list
2. Pull first item off of unsorted list
3. Put item in the correct order of new list
4. Repeat 2 & 3

**Example:**

* :pound:\[$5, $1, $10, $1, $5]
* \[$5]:pound:\[$1, $10, $1, $5]
* \[$1, $5]:pound:\[$10, $1, $5]
* \[$1, $5, $10]:pound:\[$1, $5]
* \[$1, $1, $5, $10]:pound:\[$5]
* \[$1, $1, $5, $5, $10] :pound:

:black\_joker: This type of sorting algorithm is commonly used in playing card games, & organizing cash in wallets:black\_joker:

## **Divide & Conquer Sort**:heavy\_division\_sign::crossed\_swords::rainbow:

**Divide & Conquer Sort** is an algorithm which splits the list into smaller groups, then sorts the smaller groups, then puts the sorted small groups back together.

**Divide & Conquer Sort:**

1. Split Lists in Half
2. ^ Repeat Step 1 ^
3. Merge & Sort&#x20;
4. ^ Repeat Step 3 ^

**Example:**

```
                Array
                  '
          -------------------
         '                   '
       Half                Half
         '                   '
    -----------         -----------
   '           '       '           '
Quarter    Quarter   Quarter    Quarter 
   '           '       '           '
    -----------         -----------
         '                   '
   Sorted Half         Sorted Half
         '                   '
          -------------------
                  '
            Sorted Array
```

:closed\_book:This type of sorting algorithm is commonly used when sorting big lists like the Library of Congress 15,000 book returns per day.:closed\_book:&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ksmcclay.gitbook.io/no-code-computer-science/algorithms/sort.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
