dotnet / dotnet/msbuild

[Feature Request]: Tasks - Add a Sort task

Open
#8,796 1 comment 5 reactions 0 assignees View on GitHub
backlog Feature Request gathering-feedback triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Summary

Add a `Sort` task for sorting an Item collection. Metadata can be used as sort keys.

### Background and Motivation

Sorting can be helpful or needed to make outputs from a build script more consistent and/or deterministic.

If a build script is generating information for a reporting purpose, it can be helpful to sort the information. If a build script is generating a file, it may be beneficial to sort the content before writing the file so that versions of the generated file can be more easily compared.

### Proposed Feature

Add a task named `Sort`. I can provide working code if there is interest in this feature.

#### Input parameters:

- [Required] `ITaskItem[]` `Items` - The items to sort.
- `ITaskItem[]` `OrderBy` - Optional 'order by' instructions.
- Syntax (modeled on other existing tools):
- MetadataName[ [c][asc|desc]][;MetadataName[ [c][asc|desc]][...]
- Where 'c' is a case-sensitive compare; 'asc' is ascending order; and 'desc' is descending order.
- Default when `OrderBy` is not provided, is to order by 'Identity', case-insensitive compare, ascending order.

#### Output parameters:

- `ITaskItem[]` `SortedItems` - The resulting sorted items.

#### Examples:

```xml



```

```xml



```

```xml



```

### Alternative Designs

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.