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}}==
'''Compiler:'''{{works [[with|GNAT]] |GPL 2006}}
with Gnat.Heap_Sort_G;
Line 52:
end Integer_Sort;
=={{header|C}}==
'''Compiler:'''{{works [[with|gcc]] |4.0.1}}
#include <stdlib.h>
Line 67:
 
=={{header|C++}}==
'''Compiler:'''{{works [[with|g++]] |4.0.1}}
 
===Simple Array===
Line 137:
 
=={{header|Forth}}==
{{works with|Win32Forth|4.2}}
'''Interpreter:'''[[Win32Forth]] 4.2
create test-data 2 , 4 , 3 , 1 , 2 ,
test-data 5 cell-sort
 
=={{header|Haskell}}==
'''Interpreter:'''{{works [[with|GHC|GHCi]] |6.6}}
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}}==
'''Interpreter:'''{{works with|Firefox |2.0}}
 
JavaScript sorts lexically by default, so "10000" comes before "2". To sort numerically, a custom comparator is used.
Line 203 ⟶ 204:
 
=={{header|Objective-C}}==
'''Compiler:'''{{works [[with|GCC]] |4.0.1 (apple)}}
- (void)example
{
Line 227 ⟶ 228:
 
=={{header|Perl}}==
{{works with|Perl|5.8.6}}
'''Interpreter:''' [[perl]] 5.8.6
@nums = (2,4,3,1,2);
@sorted = sort {$a <=> $b} @nums;
 
=={{header|PHP}}==
'''Interpreter:'''{{works [[with|PHP]] |4.4.4 CLI}}
<?php
$nums = array(2,4,3,1,2);
Line 265 ⟶ 266:
 
=={{header|Python}}==
'''Interpreter:'''{{works [[with|Python]] |2.3}}
nums = [2,4,3,1,2]
nums.sort()
Line 283 ⟶ 284:
 
=={{header|Ruby}}==
{{works with|Ruby|1.8.4}}
'''Interpreter:''' [[ruby]] 1.8.4
nums = [2,4,3,1,2]
sorted = nums.sort
Anonymous user