Sort
Learn about sort in fp-ts ord
Code Editor
05-sort.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('Ord sort', () => {
it('sorts users by score', () => {
const users: User[] = [
{ name: 'Alice', score: 85 },
{ name: 'Bob', score: 92 },
{ name: 'Charlie', score: 78 },
]
const result = sortByScore(users)
expect(result[0].name).toBe('Charlie')
expect(result[2].name).toBe('Bob')
})
it('clamps values', () => {
expect(clamp(0, 100, 50)).toBe(50)
expect(clamp(0, 100, -10)).toBe(0)
expect(clamp(0, 100, 150)).toBe(100)
})
})🧪
Ready to Test?
Click "Run Tests" to see how your code performs
Quick Tips
•Read the TODO comments in the code
•Use Reset to restore original code
•Check Solution if stuck
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