Module std::sort

Sorting utilities for vectors.

Provides type-specific sort and reverse functions. Each returns a new vector โ€” the original is never modified.

Examples

import std::sort;

fn main() {
    let nums: Vec<i64> = Vec::new();
    nums.push(3);
    nums.push(1);
    nums.push(2);
    let sorted = sort.sort_ints(nums);
    // sorted is [1, 2, 3]
}

Contents

Functions

Function sort_ints

pub fn sort_ints(v: Vec<i64>) -> Vec<i64>

Sort a vector of integers in ascending order.

Returns a new sorted vector; the original is unchanged.

Function sort_strings

pub fn sort_strings(v: Vec<string>) -> Vec<string>

Sort a vector of strings in alphabetical order.

Returns a new sorted vector; the original is unchanged.

Function sort_floats

pub fn sort_floats(v: Vec<f64>) -> Vec<f64>

Sort a vector of floats in ascending order.

Returns a new sorted vector; the original is unchanged.

Function reverse_ints

pub fn reverse_ints(v: Vec<i64>) -> Vec<i64>

Reverse a vector of integers.

Returns a new reversed vector; the original is unchanged.

Function reverse_strings

pub fn reverse_strings(v: Vec<string>) -> Vec<string>

Reverse a vector of strings.

Returns a new reversed vector; the original is unchanged.

Function reverse_floats

pub fn reverse_floats(v: Vec<f64>) -> Vec<f64>

Reverse a vector of floats.

Returns a new reversed vector; the original is unchanged.