Key Facts
- Category
- Data Processing
- Input Types
- textarea
- Output Type
- text
- Sample Coverage
- 4
- API Ready
- Yes
Overview
The Sorted Unique tool efficiently removes consecutive duplicate values from a sorted JSON array using the lodash _.sortedUniq function. It ensures your data is clean and unique, ideal for preprocessing sorted datasets.
When to Use
- •When you have a pre-sorted array and need to eliminate duplicate entries.
- •To optimize data storage by removing redundant values in sorted lists.
- •Before performing operations that require unique elements, such as set operations or analysis.
How It Works
- •Input a JSON array that is already sorted in ascending order.
- •The tool applies the lodash _.sortedUniq function to identify and remove consecutive duplicates.
- •It returns a new JSON array containing only the unique values in their original order.
Use Cases
Examples
1. Remove Duplicates from Sorted Timestamps
Data Analyst- Background
- You have a sorted list of event timestamps from a log file, but some events are logged multiple times consecutively.
- Problem
- The array has duplicate timestamps that need to be removed for accurate analysis.
- How to Use
- Enter the sorted JSON array of timestamps into the tool's input field.
- Outcome
- The tool returns a new array with consecutive duplicate timestamps removed, e.g., [1625097600, 1625097601, 1625097603].
2. Deduplicate Sorted Product Codes
Inventory Manager- Background
- You have a sorted list of product codes from an inventory scan, but some codes appear multiple times in a row due to scanning errors.
- Problem
- Need to clean the list to get unique product codes for stock reconciliation.
- How to Use
- Paste the sorted array of product codes into the tool.
- Outcome
- A unique list of product codes is generated, such as ['A001', 'A002', 'B001'].
Try with Samples
json, videoRelated Hubs
FAQ
What does the Sorted Unique tool do?
It removes consecutive duplicate values from a sorted JSON array using lodash _.sortedUniq.
Does the array need to be sorted?
Yes, the tool requires the input array to be sorted for _.sortedUniq to work correctly.
What input format is accepted?
You must provide a valid JSON array, such as [1, 1, 2, 3].
Can it handle non-numeric data?
Yes, it works with any data type that can be compared, as long as the array is sorted.
Is the original array modified?
No, the tool returns a new array with duplicates removed, leaving the input unchanged.