Anonymous user
Sort an integer array: Difference between revisions
m
Changed over to works with template
No edit summary |
m (Changed over to works with template) |
||
Line 25:
=={{header|Ada}}==
with Gnat.Heap_Sort_G;
Line 52:
end Integer_Sort;
=={{header|C}}==
#include <stdlib.h>
Line 67:
=={{header|C++}}==
===Simple Array===
Line 137:
=={{header|Forth}}==
{{works with|Win32Forth|4.2}}
create test-data 2 , 4 , 3 , 1 , 2 ,
test-data 5 cell-sort
=={{header|Haskell}}==
nums = [2,4,3,1,2] :: [Int]
Line 174:
===List===
{{works with|Java|1.5+}}
import java.util.Arrays;
import java.util.Collections;
Line 187 ⟶ 188:
=={{header|JavaScript}}==
JavaScript sorts lexically by default, so "10000" comes before "2". To sort numerically, a custom comparator is used.
Line 203 ⟶ 204:
=={{header|Objective-C}}==
- (void)example
{
Line 227 ⟶ 228:
=={{header|Perl}}==
{{works with|Perl|5.8.6}}
@nums = (2,4,3,1,2);
@sorted = sort {$a <=> $b} @nums;
=={{header|PHP}}==
<?php
$nums = array(2,4,3,1,2);
Line 265 ⟶ 266:
=={{header|Python}}==
nums = [2,4,3,1,2]
nums.sort()
Line 283 ⟶ 284:
=={{header|Ruby}}==
{{works with|Ruby|1.8.4}}
nums = [2,4,3,1,2]
sorted = nums.sort
|