"""
    zigzag_ordering(array::Array{Int64,1})

`zigzag_ordering` reorders an unsorted array in the zigzag fashion. This procedure implies
that between every second step a break will be generated by switching the `flag-boolean`.


# Arguments
- `array::Array{Int64,1}`: Unsorted array


# Examples
```julia-repl
julia> import ClassicAlgorithmsCollections
julia> arr = [4, 3, 7, 8, 6, 2, 1, 10, 13, 3]
julia> ClassicAlgorithmsCollections.zigzag_ordering(arr)
[3, 7, 4, 8, 2, 6, 1, 13, 3, 10]
```
"""
function zigzag_ordering(array::Array{Int64,1})
    # Intialize the flag
    flag = true
    for i in 1:length(array)-1
        # If flag is true, then check if next array element is greater than previous
        if flag
            if array[i] > array[i+1]
                array[i], array[i+1] = array[i+1], array[i]
            end
            # If flag is true, then check if next array element is smaller than previous
        else
            if array[i] < array[i+1]
                array[i], array[i+1] = array[i+1], array[i]
            end
        end
        # Swapt the flag after every turn
        flag = !flag
    end
    return array
end
