{"id":15699018,"url":"https://github.com/pgilad/gulp-sort","last_synced_at":"2025-04-14T22:50:55.605Z","repository":{"id":25259609,"uuid":"28684757","full_name":"pgilad/gulp-sort","owner":"pgilad","description":"Sort files in stream by path or any custom sort comparator","archived":false,"fork":false,"pushed_at":"2019-02-13T09:27:54.000Z","size":10,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T10:54:09.511Z","etag":null,"topics":["gulp","gulp-plugin","pipeline","sort","stream","utiliy"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgilad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-01T10:35:54.000Z","updated_at":"2023-12-09T11:13:14.000Z","dependencies_parsed_at":"2022-08-28T21:41:45.768Z","dependency_job_id":null,"html_url":"https://github.com/pgilad/gulp-sort","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Fgulp-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgilad","download_url":"https://codeload.github.com/pgilad/gulp-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788302,"owners_count":21161721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-plugin","pipeline","sort","stream","utiliy"],"created_at":"2024-10-03T19:37:27.710Z","updated_at":"2025-04-14T22:50:55.572Z","avatar_url":"https://github.com/pgilad.png","language":"JavaScript","readme":"# [gulp](https://github.com/wearefractal/gulp)-sort\n\u003e Sort files in stream by path or any custom sort comparator\n\n[![Build Status](http://img.shields.io/travis/pgilad/gulp-sort/master.svg?style=flat)](https://travis-ci.org/pgilad/gulp-sort)\n\n## Install\n\n`$ npm install gulp-sort --save-dev`\n\n## Usage\n\n```js\nvar sort = require('gulp-sort');\n\n// default sort\ngulp.src('./src/js/**/*.js')\n    .pipe(sort())\n    .pipe(gulp.dest('./build/js'));\n\n// pass in a custom comparator function\ngulp.src('./src/js/**/*.js')\n    .pipe(sort(customComparator))\n    .pipe(gulp.dest('./build/js'));\n\n// sort descending\ngulp.src('./src/js/**/*.js')\n    .pipe(sort({\n         asc: false\n    }))\n    .pipe(gulp.dest('./build/js'));\n\n// sort with a custom comparator\ngulp.src('./src/js/**/*.js')\n    .pipe(sort({\n        comparator: function(file1, file2) {\n            if (file1.path.indexOf('build') \u003e -1) {\n                return 1;\n            }\n            if (file2.path.indexOf('build') \u003e -1) {\n                return -1;\n            }\n            return 0;\n        }\n    }))\n    .pipe(gulp.dest('./build/js'));\n\n// sort with a custom sort function\nvar stable = require('stable');\ngulp.src('./src/js/**/*.js')\n    .pipe(sort({\n        customSortFn: function(files, comparator) {\n            return stable(files, comparator);\n        }\n    }))\n    .pipe(gulp.dest('./build/js'));\n```\n\n## Options\n\n`gulp-sort` takes in an optional [comparator](#comparator) function, or dictionary with following params:\n\n### asc\n\nSort ascending. Defaults to true. Specify false to sort descending.\n\n### comparator\n\nComparator function to use. `comparator(file1, file2)`. Defaults to `localeCompare` of file paths.\n\n### customSortFn\n\nUse `customSortFn` in order to control the sorting yourself (useful for stable sorts).\n\n`customSortFn` signature is as follows:\n\n`customSortFn(\u003cfiles\u003e, \u003ccomparator\u003e)`\n\n- `files` being the vinyl file objects that were passed in\n- `comparator` is the default comparator used, or a custom one that was passed as param\n\nThis function is expected to return back the sorted list of files.\n\n## License\n\nMIT © [Gilad Peleg](https://www.giladpeleg.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Fgulp-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgilad%2Fgulp-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Fgulp-sort/lists"}