Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Write a bubble sort in Rust
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Write a bubble sort in Rust
- Assistant
Here is a possible implementation of bubble sort in Rust:
rust// A function to sort a vector of integers using bubble sort fn bubble_sort(mut v: Vec<i32>) -> Vec<i32> { // Get the length of the vector let n = v.len(); // Loop over the vector n-1 times for i in 0..n-1 { // Loop over the unsorted part of the vector for j in 0..n-i-1 { // If the current element is larger than the next one, swap them if v[j] > v[j+1] { v.swap(j, j+1); } } } // Return the sorted vector v } // A function to test the bubble sort function fn main() { // Create a vector of integers let v = vec![5, 3, 8, 2, 6, 4, 7, 1]; // Print the original vector println!("Original vector: {:?}", v); // Sort the vector using bubble sort let sorted_v = bubble_sort(v); // Print the sorted vector println!("Sorted vector: {:?}", sorted_v); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)