Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/common/utils/projectOrdering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ describe("projectOrdering", () => {
};

describe("sortProjectsByOrder", () => {
it("returns natural order when order array is empty", () => {
it("returns lexical order when order array is empty", () => {
const projects = createProjects(["/a", "/c", "/b"]);
const result = sortProjectsByOrder(projects, []);
expect(result.map(([p]) => p)).toEqual(["/a", "/c", "/b"]);
expect(result.map(([p]) => p)).toEqual(["/a", "/b", "/c"]);
});

it("sorts projects according to order array", () => {
Expand Down
5 changes: 4 additions & 1 deletion src/common/utils/projectOrdering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export function sortProjectsByOrder(
): Array<[string, ProjectConfig]> {
const entries = Array.from(projects.entries());

if (order.length === 0) return entries; // Natural order
if (order.length === 0) {
// Sort lexically for stable, deterministic order
return entries.sort(([a], [b]) => a.localeCompare(b));
}

const pos = new Map(order.map((p, i) => [p, i]));

Expand Down