Skip to content

Commit

Permalink
implement a free sorted_unstable
Browse files Browse the repository at this point in the history
- based on free `sorted`
  • Loading branch information
chris-ha458 authored and jswrenn committed Nov 13, 2023
1 parent e44dd53 commit 9c302ce
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/free.rs
Expand Up @@ -295,3 +295,22 @@ where
{
iterable.into_iter().sorted()
}

/// Sort all iterator elements into a new iterator in ascending order.
/// This sort is unstable (i.e., may reorder equal elements).
/// [`IntoIterator`] enabled version of [`Itertools::sorted_unstable`].
///
/// ```
/// use itertools::sorted_unstable;
/// use itertools::assert_equal;
///
/// assert_equal(sorted_unstable("rust".chars()), "rstu".chars());
/// ```
#[cfg(feature = "use_alloc")]
pub fn sorted_unstable<I>(iterable: I) -> VecIntoIter<I::Item>
where
I: IntoIterator,
I::Item: Ord,
{
iterable.into_iter().sorted_unstable()
}

0 comments on commit 9c302ce

Please sign in to comment.