Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

alexandria_sorting

Fully qualified path: alexandria_sorting

Modules

interface
merge_sortMerge Sort
quick_sortQuick sort algorithm
bubble_sortBubble sort algorithm

Re-exports:

SortableTrait for sorting algorithms that work with Array spans
SortableVecTrait for sorting algorithms that work with Felt252Vec

BubbleSort
MergeSort
QuickSortImplementation of QuickSort algorithm for Felt252Vec

Modules

Modules

interface
merge_sortMerge Sort
quick_sortQuick sort algorithm
bubble_sortBubble sort algorithm

interface

Fully qualified path: alexandria_sorting::interface

Traits

SortableTrait for sorting algorithms that work with Array spans
SortableVecTrait for sorting algorithms that work with Felt252Vec

Traits

Traits

SortableTrait for sorting algorithms that work with Array spans
SortableVecTrait for sorting algorithms that work with Felt252Vec

Sortable

Trait for sorting algorithms that work with Array spans

Fully qualified path: alexandria_sorting::interface::Sortable

pub trait Sortable

Trait functions

sort

Sorts a span of elements and returns a new sorted array

Fully qualified path: alexandria_sorting::interface::Sortable::sort

fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>>(array: Span<T>) -> Array<T>

SortableVec

Trait for sorting algorithms that work with Felt252Vec

Fully qualified path: alexandria_sorting::interface::SortableVec

pub trait SortableVec

Trait functions

sort

Sorts a Felt252Vec and returns a new sorted Felt252Vec

Fully qualified path: alexandria_sorting::interface::SortableVec::sort

fn sort<T, +Copy<T>, +Drop<T>, +PartialOrd<T>, +Felt252DictValue<T>>(
    array: Felt252Vec<T>,
) -> Felt252Vec<T>

merge_sort

Merge Sort

Fully qualified path: alexandria_sorting::merge_sort

Impls

Impls

Impls

MergeSort

Fully qualified path: alexandria_sorting::merge_sort::MergeSort

pub impl MergeSort of Sortable;

Impl functions

sort

Arguments

  • arr - Array to sort

Returns

  • Array<T> - Sorted array

Fully qualified path: alexandria_sorting::merge_sort::MergeSort::sort

fn sort(mut array: Span<T>) -> Array<T>

quick_sort

Quick sort algorithm

Fully qualified path: alexandria_sorting::quick_sort

Impls

QuickSortImplementation of QuickSort algorithm for Felt252Vec

Impls

Impls

QuickSortImplementation of QuickSort algorithm for Felt252Vec

QuickSort

Implementation of QuickSort algorithm for Felt252Vec

Fully qualified path: alexandria_sorting::quick_sort::QuickSort

pub impl QuickSort of SortableVec;

Impl functions

sort

Sorts a Felt252Vec using the QuickSort algorithm Time complexity: O(n log n) average case, O(n²) worst case Space complexity: O(log n) due to recursion

Arguments

  • Felt252Vec<T> - Array to sort

Returns

  • Felt252Vec<T> - Sorted array

Fully qualified path: alexandria_sorting::quick_sort::QuickSort::sort

fn sort(mut array: Felt252Vec<T>) -> Felt252Vec<T>

bubble_sort

Bubble sort algorithm

Fully qualified path: alexandria_sorting::bubble_sort

Impls

Impls

Impls

BubbleSort

Fully qualified path: alexandria_sorting::bubble_sort::BubbleSort

pub impl BubbleSort of Sortable;

Impl functions

sort

Fully qualified path: alexandria_sorting::bubble_sort::BubbleSort::sort

fn sort(mut array: Span<T>) -> Array<T>