<commit_before>---
layout: default
title: 冒泡排序
---


冒泡排序
===================

尽量每个工作日学一个算法，用JS实现，放在博客里，虽说前端用到算法的时候好像貌似似乎不多，但是学学还是好的，万一用上了呢？


	var arr = [25,32,7,14,99];
	var x = 1;
	length = arr.length;
	while(x <= (length - 1)){
		for (var i = 0; i < (arr.length-x); i++) {
			var that = arr[i];
			var cthat = arr[i+1];
			if(that<cthat){
		        var val = that;
		        arr[i] = cthat;
		        arr[i+1] = val;
		    }
		};
		x++;
	}








<commit_msg>modify my blog<commit_after>---
layout: default
title: 冒泡排序
---


冒泡排序
===================

打算接下来的时间有空就学学算法，用JS实现，放在博客里，虽说前端用到算法的时候好像貌似似乎不多，但是学学还是好的，万一用上了呢？


	var arr = [25,32,7,14,99];
	var x = 1;
	length = arr.length;
	while(x <= (length - 1)){
		for (var i = 0; i < (arr.length-x); i++) {
			var that = arr[i];
			var cthat = arr[i+1];
			if(that<cthat){
		        var val = that;
		        arr[i] = cthat;
		        arr[i+1] = val;
		    }
		};
		x++;
	}









{'fraction_non_alphanumeric': 0.2167381974248927, 'fraction_numerical': 0.030042918454935622, 'mean_word_length': 2.368231046931408, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4019379', 'n_tokens_mistral': 558, 'n_tokens_neox': 502, 'n_words': 82}