PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Jane Street

Sort trade executions into a canonical order

Last updated: Apr 27, 2026

Quick Overview

This question evaluates a candidate's ability to enforce deterministic ordering and data normalization of time-series trade execution records, testing competencies in multi-key sorting, tie-breaking logic, and performance with large inputs.

  • easy
  • Jane Street
  • Coding & Algorithms
  • Software Engineer

Sort trade executions into a canonical order

Company: Jane Street

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

You are building a small component in a trading system that consumes **trade execution records** from an upstream feed. The records may arrive out of order. Each trade record has: - `trade_id` (string, unique) - `symbol` (string) - `ts` (integer timestamp in milliseconds) - `price` (integer, in ticks) - `qty` (integer, > 0) - `side` (`"B"` or `"S"`) **Task**: Implement a function that takes an array of trade records and returns them sorted in a deterministic “canonical” order: 1. Increasing `ts` 2. If `ts` ties, increasing `symbol` (lexicographic) 3. If still tied, increasing `trade_id` (lexicographic) **Input/Output**: - Input: list of trade records - Output: the same records sorted by the rule above **Constraints** (assume): - Up to 2e5 trades - `trade_id` values are unique - Sorting must be deterministic **Follow-up** (optional): Describe how you would handle the case where `trade_id` is not guaranteed unique (duplicates/replays).

Quick Answer: This question evaluates a candidate's ability to enforce deterministic ordering and data normalization of time-series trade execution records, testing competencies in multi-key sorting, tie-breaking logic, and performance with large inputs.

Related Interview Questions

  • Optimize trade PnL table updates - Jane Street (hard)
  • Transform sparse time-code stream to dense rows - Jane Street (easy)
  • Solve queue switch and coin change puzzles - Jane Street (medium)
  • Implement Connect Four with bottom push-up - Jane Street (Medium)
Jane Street logo
Jane Street
Dec 15, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
43
0

You are building a small component in a trading system that consumes trade execution records from an upstream feed. The records may arrive out of order.

Each trade record has:

  • trade_id (string, unique)
  • symbol (string)
  • ts (integer timestamp in milliseconds)
  • price (integer, in ticks)
  • qty (integer, > 0)
  • side ( "B" or "S" )

Task: Implement a function that takes an array of trade records and returns them sorted in a deterministic “canonical” order:

  1. Increasing ts
  2. If ts ties, increasing symbol (lexicographic)
  3. If still tied, increasing trade_id (lexicographic)

Input/Output:

  • Input: list of trade records
  • Output: the same records sorted by the rule above

Constraints (assume):

  • Up to 2e5 trades
  • trade_id values are unique
  • Sorting must be deterministic

Follow-up (optional): Describe how you would handle the case where trade_id is not guaranteed unique (duplicates/replays).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Jane Street•More Software Engineer•Jane Street Software Engineer•Jane Street Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.