FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/src/test/java/sort/basic/SelectSort.java at master · verifyCode/algorithms · GitHub
verifyCode
algorithms
Repository navigation
Code
Issues
Pull requests
2
(2)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
src
/
test
/
java
/
sort
/
basic
/
SelectSort.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (26 loc) · 760 Bytes
Breadcrumbs
algorithms
/
src
/
test
/
java
/
sort
/
basic
/
SelectSort.java
Copy path
File metadata and controls
32 lines (26 loc) · 760 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package
sort
.
basic
;
import
com
.
sort
.
SortTestHelper
;
import
java
.
util
.
Arrays
;
/**
* @author xjn
* @since 2020-05-07
*/
public
class
SelectSort
{
public
static
void
sort
(
int
[]
array
) {
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++) {
int
minIndex
=
i
;
for
(
int
j
=
i
+
1
;
j
<
array
.
length
;
j
++) {
if
(
array
[
j
] <
array
[
minIndex
]) {
minIndex
=
j
;
}
}
SortTestHelper
.
swap
(
array
,
minIndex
,
i
);
}
}
public
static
void
main
(
String
[]
args
) {
int
[]
ints
=
SortTestHelper
.
generateRandomArray
(
10
,
1
,
10
);
System
.
out
.
println
(
Arrays
.
toString
(
ints
));
sort
(
ints
);
System
.
out
.
println
(
Arrays
.
toString
(
ints
));
}
}
Back
|
FazBrowse Home
|
New Git URL