Sort

intermediate6 of 10

Learn about sort in fp-ts array

Code Editor

06-sort.exercise.ts

💻
Loading editor...
Preparing Monaco Editor with TypeScript support

Test Results

Requirements

describe('Array sort operations', () => {
  it('sorts numbers in ascending order', () => {
    const result = sortNumbersAscending([5, 2, 8, 1, 9])
    expect(result).toEqual([1, 2, 5, 8, 9])
  })

  it('handles empty array', () => {
    const result = sortNumbersAscending([])
    expect(result).toEqual([])
  })

  it('sorts users by age', () => {
    const users = [
      { name: 'Alice', age: 30 },
      { name: 'Bob', age: 25 },
      { name: 'Charlie', age: 35 },
    ]
    const result = sortUsersByAge(users)
    expect(result).toEqual([
      { name: 'Bob', age: 25 },
      { name: 'Alice', age: 30 },
      { name: 'Charlie', age: 35 },
    ])
  })
})
🧪

Ready to Test?

Click "Run Tests" to see how your code performs

Pro Tips

💡 Stuck? Here's what to try:

  • • Read the comments in the code carefully
  • • Run tests frequently to get feedback
  • • Check the fp-ts documentation
  • • Use the solution if you need help

🚀 Learning Approach:

  • • Focus on understanding, not just solving
  • • Experiment with different approaches
  • • Think about real-world applications
  • • Build on previous exercises