IntelliDataSort is a high-performance, culture-aware sorting and parsing library for .NET, designed to safely handle real-world mixed data. It supports robust sorting of numbers, dates, file sizes, percentages, IP addresses, natural strings, versions, and currencies, with strong validation to prevent malformed, ambiguous, or malicious inputs. The library guarantees stable sorting, configurable string comparison rules, detailed parsed-value extraction, and strict edge-case handling across international formats.
$ dotnet add package IntelliDataSortSecure, culture-aware sorting and parsing engine for real-world string data
IntelliDataSort (powered by HumanSort) is a high-precision sorting library for .NET designed to safely handle untrusted, mixed-format, and international string data.
It combines:
Ideal for data grids, reports, logs, CSV/Excel imports, admin panels, and console tooling where correctness and security matter.
Common issues with traditional sorting:
"file10" sorted before "file2""₹1,00,000" treated as invalid"04/07/2023" misinterpreted across culturesHumanSort solves these with explicit type declaration and strict validation.
out parameter for post-sort filteringparsed = null)dotnet add package IntelliDataSort
using IntelliDataSort;
var sorter = new HumanSort();
var data = new List<string>
{
"file10",
"file2",
"file1"
};
// REQUIRED: Explicitly specify column type
var result = sorter.Sort(
data,
HumanSort.ColumnType.NaturalString, // ← MANDATORY parameter
ascending: true,
nullHandling: HumanSort.NullHandling.NullsFirst
);
// Result: ["file1", "file2", "file10"]
forceType is now a REQUIRED non-nullable parameter.
Auto-detection has been removed to prevent silent failures and ambiguous behavior.
✅ Correct usage:
sorter.Sort(data, HumanSort.ColumnType.Number, true);
❌ Will not compile:
// Missing required forceType parameter
sorter.Sort(data, true);
Why this change? Ambiguous inputs like
"1.234"could mean1.234(decimal) or1234(thousands separator) depending on culture. HumanSort requires explicit intent to guarantee deterministic results.
| ColumnType | Description | Example Values |
|---|---|---|
Number | Integers, decimals, scientific notation | 123, -45.67, 1.23e4, 0xFF |
DateTime | Culture-aware date & time parsing | 2023-07-04, 04/07/2023 |
Currency | Symbol & ISO-aware currency parsing | $100, ₹1,00,000, 100 EUR |
Percentage | Strict % parsing | 10%, (15%), 25 pct |
FileSize | B → YB (decimal & binary) | 1 KB, 1 MiB, 0.5 GB |
IpAddress | Exact IPv4 sorting | 192.168.1.1, 10.0.0.1 |
NaturalString | Human-friendly alphanumeric sorting | file1, file10, doc_v2 |
Version | Semantic versioning (SemVer) | 1.0.0, 2.0.0-beta, 3.14.159 |
PlainString | Ordinal string comparison | "apple", "banana" |
var data = new List<string>
{
"(₹1,00,000)",
"₹10",
"₹1,00,00,000"
};
var result = sorter.Sort(
data,
HumanSort.ColumnType.Currency,
ascending: true,
nullHandling: HumanSort.NullHandling.NullsFirst
);
✔ Parentheses negatives: (₹100) → -100
✔ Indian numbering system (lakh/crore)
✔ Strict validation (rejects ambiguous inputs)
✔ No mixed-currency coercion
var culture = new CultureInfo("en-GB"); // Day-first culture
var data = new List<string>
{
"04/07/2023", // 4 July 2023 (not April!)
"01/12/2024",
"07/08/2022"
};
var result = sorter.Sort(
data,
HumanSort.ColumnType.DateTime,
ascending: true,
nullHandling: null,
dateTimeCulture: culture, // ← Only valid for DateTime
out var parsedValues
);
⚠️
dateTimeCultureparameter is only accepted whenforceType = ColumnType.DateTime. Using it with other types throwsArgumentException.
var data = new List<string>
{
"10%",
"(15%)", // → -15
"25 pct",
"50 percent"
};
var result = sorter.Sort(
data,
HumanSort.ColumnType.Percentage,
ascending: true
);
Accepted: 10%, (15%), 25 pct, 50 percent, -30%
Rejected: 100 (no % indicator), $50, 10% KB, percent 50
All sort operations support an out parameter for parsed values:
var result = sorter.Sort(
data,
HumanSort.ColumnType.Number,
ascending: true,
nullHandling: null,
out List<(string original, object parsed)> parsedValues
);
// Inspect parsed values for filtering/auditing
foreach (var (original, parsed) in parsedValues)
{
Console.WriteLine($"{original} → {parsed ?? "INVALID"}");
}
| Input | Parsed Value Type | Notes |
|---|---|---|
| Valid item | double, DateTime, etc. | Type matches ColumnType |
| Invalid | null | Explicitly marked invalid |
Zero-trust input philosophy: Ambiguous or potentially malicious inputs are rejected, not guessed.
' OR 1=1 --)<script>)100$€)$1e5)$X)Security Note: This parser implements strict allow-list validation per OWASP guidelines. It reduces injection risk at the input boundary but does not replace downstream security controls (parameterized queries, output encoding, access control).
namespace IntelliDataSort
{
public sealed class HumanSort
{
public enum ColumnType { ... }
public enum NullHandling { ... }
public enum NaturalSortCaseSensitivity { ... }
public HumanSort();
public IReadOnlyList<string> Sort(
IEnumerable<string> data,
ColumnType forceType, // ← REQUIRED (non-nullable)
bool ascending = true,
NullHandling? nullHandling = null
);
public IReadOnlyList<string> Sort(
IEnumerable<string> data,
ColumnType forceType,
bool ascending,
NullHandling? nullHandling,
out List<(string original, object parsed)> parsedValues
);
public IReadOnlyList<string> Sort(
IEnumerable<string> data,
ColumnType forceType,
bool ascending,
NullHandling? nullHandling,
CultureInfo dateTimeCulture, // ← DateTime only
out List<(string original, object parsed)> parsedValues
);
// ===== VALIDATION METHODS =====
public bool IsValidCurrencyLiteral(string input);
public bool IsValidCurrencyLiteral(string input, string expectedCurrencyCode);
public static bool IsValidIpAddressExact(string input);
public IReadOnlyCollection<string> GetCurrencySymbols();
public IReadOnlyCollection<string> GetCurrencyCodes();
}
}
NumberValidator, CurrencyValidator, etc.) → internalVersionParser, TokenListComparer, etc.) → private/internalprivate sealedprivate static readonlyProprietary License
© 2026 Mohd Nasrullah Kazmi (IntelliDataSort).
All rights reserved.
Unauthorized copying, modification, distribution, or commercial use is prohibited unless explicitly permitted by the author.