Math Utilities

Rank Numbers

Sorts numerical arrays by rank from largest to smallest or vice versa via GET /v1/math/rank. Perfect for MCP-enabled editors like Cursor when processing datasets, leaderboards, or statistical analysis. Returns ranked positions with original values preserved. Handles integers, decimals, and negative numbers with deterministic ordering for consistent AI agent workflows.

API Endpoint

GET /v1/math/rank

Code Examples

curl "https://tinyfn.io/v1/math/rank" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/rank', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/math/rank',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's math tools:

{
  "mcpServers": {
    "tinyfn-math": {
      "url": "https://tinyfn.io/mcp/math",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I rank numbers from smallest to largest instead of largest to smallest?

Use the ascending parameter in your request. The default behavior ranks from largest to smallest (descending=true).

What happens when my list contains duplicate numbers?

Duplicate values receive the same rank, with subsequent ranks adjusted accordingly (e.g., two items tied for 2nd place means the next item gets 4th place).

Can I rank decimal numbers and negative values?

Yes, the tool handles all numeric types including decimals, negative numbers, and scientific notation with proper mathematical ordering.

How does this work with MCP in Cursor for data analysis?

Cursor can call the rank function directly on arrays in your code, making it instant to sort performance metrics, scores, or any numerical data during development.

Does the ranking preserve the original array structure?

The response includes both the ranked positions and original values, so you can map rankings back to your source data or identifiers.

Try Rank Numbers Now

Get your free API key and start using Rank Numbers in seconds.

Get Free API Key