Navigation

HomeImage ToolsCode ToolsMath ToolsDate ToolsGeneratorsUtilities
Color ToolsText ToolsPDF Tools

Create Integer Zigzag Online

Rearrange a list of integers into a zigzag pattern where elements alternate between local minima and maxima.

Drop in a list of numbers and the tool rearranges them so they bounce — small, big, small, big — across the whole sequence. Handy when you need messy test data for a sorting algorithm or want to break the monotonic order of a dataset before charting it. And everything runs in your browser. Nothing gets uploaded.

How It Works

A zigzag arrangement ensures arr[0] < arr[1] > arr[2] < arr[3] > ... (or the reverse). The algorithm sorts the array, then swaps adjacent pairs to create the alternating pattern. The visualization shows the resulting zigzag as a bar chart.

Related Tools