| Crates.io | vibesort-rs |
| lib.rs | vibesort-rs |
| version | 0.2.2 |
| created_at | 2025-11-26 02:19:23.867422+00 |
| updated_at | 2025-12-01 02:11:17.206804+00 |
| description | Sort arrays using Large Language Models (LLMs) |
| homepage | |
| repository | https://github.com/fileng87/vibesort-rs |
| max_upload_size | |
| id | 1950839 |
| size | 69,777 |
Sort arrays using Large Language Models (LLMs).
Add this to your Cargo.toml:
[dependencies]
vibesort-rs = "0.2.2"
tokio = { version = "1.48", features = ["rt", "macros"] }
use vibesort_rs::Vibesort;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let sorter = Vibesort::new(
"your-api-key",
"gpt-5",
"https://api.openai.com/v1",
);
let numbers = vec![3, 1, 4, 1, 5, 9, 2, 6];
let sorted = sorter.sort(&numbers).await?;
println!("{:?}", sorted); // [1, 1, 2, 3, 4, 5, 6, 9]
Ok(())
}
For sorting string arrays, you can use the convenient sort_str method:
use vibesort_rs::Vibesort;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let sorter = Vibesort::new(
"your-api-key",
"gpt-5",
"https://api.openai.com/v1",
);
let words = vec!["banana", "apple", "cherry"];
let sorted = sorter.sort_str(&words).await?;
println!("{:?}", sorted); // ["apple", "banana", "cherry"]
Ok(())
}
use vibesort_rs::{Vibesort, VibesortError};
match sorter.sort(&numbers).await {
Ok(sorted) => println!("Sorted: {:?}", sorted),
Err(VibesortError::ApiError(msg)) => eprintln!("API error: {}", msg),
Err(e) => eprintln!("Error: {}", e),
}
This project is licensed under the MIT License. See the LICENSE file for details.