Skip to content

RebekahJ/sort-selection-asc

Repository files navigation

sort-selection-asc

Build Status Coverage Status

sel( arr )

Sorts an unsorted numeric array into ascending order using a selection sort.

Examples

// Direct to lib directory
var sel = require( './../lib' );

// Create some data
var data = new Array( 5 );
for ( var i = 0; i < data.length; i++ ) {
	data[ i ] = Math.round( Math.random()*100 );
}
//var data = [ 5, 7, 3 ]

// Print data for comparison
console.log("Pre-sort:")
for ( var i = 0; i < data.length; i++ ) {
	console.log( data[i] );
}

// Sort data
sel( data );

// Print sorted array
console.log("Post-sort:")
for ( var i = 0; i < data.length; i++ ) {
	console.log( data[i] );
}

Notes

Performance

For an unsorted array of size n, the time to sort the array using bubble sort is:

n Time (ms)
5 10.0
50 10.1
500 13.0
5000 57.3
50000 4541

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Copyright

Copyright © 2014. Rebekah Smith.

About

Selection sort for a numeric array.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published