题库选项随机排序显示_数组排序选项

news/2024/7/19 14:53:26 标签: python, java, 排序算法, js, javascript
题库选项随机排序显示

题库选项随机排序显示

When sorting an array, for example by using sort() there are three constants you can use to determine how the sorting will work:

在对数组进行排序时(例如,通过使用sort()),可以使用三个常量来确定排序的工作方式:

  • SORT_REGULAR (default) when you have mixed types of variables in the array it won't cast them. The results can be ... hmm .. interesting. It will sort first all string types and them all numeric types

    SORT_REGULAR(默认),当您在数组中混合使用多种类型的变量时,将不会进行强制转换。 结果可能是...嗯..有趣。 它将首先对所有字符串类型和所有数字类型进行排序
  • SORT_NUMERIC - all elements will be casted to their numeric values

    SORT_NUMERIC-所有元素都将强制转换为其数值
  • SORT_STRING - all array elements will be sorted as strings.

    SORT_STRING-所有数组元素都将按字符串排序。

Here's an example of the three options:

这是三个选项的示例:

< ?php echo '

<?php echo'

';
$a = array(3, 1, '01', '011', '0001', 'a', 'a0', 'b0', '0b0', '1a1', '0a0', 'xyz', '99a', 991, '992');
sort($a, SORT_REGULAR); // default
print_r($a);
sort($a, SORT_NUMERIC);
print_r($a);
sort($a, SORT_STRING);
print_r($a);
?>
The result will be:

Tell your friends about this post on Facebook and Twitter

';
$a = array(3, 1, '01', '011', '0001', 'a', 'a0', 'b0', '0b0', '1a1', '0a0', 'xyz', '99a', 991, '992');
sort($a, SORT_REGULAR); // default
print_r($a);
sort($a, SORT_NUMERIC);
print_r($a);
sort($a, SORT_STRING);
print_r($a);
?>
The result will be:

Tell your friends about this post on Facebook and Twitter

翻译自: https://www.phpied.com/array-sorting-options/

题库选项随机排序显示


http://www.niftyadmin.cn/n/1306813.html

相关文章

eps倾斜摄影矢量化采集毕业设计_倾斜摄影与三维实景建模技术设计书.PDF(文档可下载)...

前两天我们分享了↓↓↓1&#xff1a;1000地形图数字摄影测量技术设计书.doc无人机倾斜摄影1:500房屋测量技术设计书.docx两篇设计书今天分享的是&#xff1a;倾斜摄影与三维实景建模技术设计书.pdf以上文档供大家参考学习老规矩文末有本文档下载链接进入本公众号后台发送数字0…

dojo中的dojox/grid/EnhancedGrid表格报错

1、错误截图 2、错误出处 <body class"claro"><div id"gridContainer"><span id"jsonStore"url"data.json"data-dojo-id"jsonStore"data-dojo-type"dojo/data/ItemFileWriteStore"></span&g…

遍历数组对象_遍历数组

遍历数组对象The certification guide demonstrates what is probably the fastest (performance-wise) way to go through the elements of an array - using the array_walk() function. The example in the guide is using a callback function to use the elements of the …

inno setup 中文乱码问题_Matplotlib中文乱码问题解决方案

Matplotlib是Python的一个2D绘图库&#xff0c;许多小伙伴第一次使用图表绘制时&#xff0c;会发现中文乱码或者小方框的情况原因是Matplotlib默认字体并不包含中文&#xff0c;所以必须设置为中文字体准备工作&#xff1a;系统&#xff1a;Windows环境管理器&#xff1a;Anaco…

FusionCharts饼图中label值太长怎么解决

FusionCharts饼图中label值太长怎么解决 1、使用hoverText属性 <?xml version"1.0" encoding"UTF-8"?> <chart captionCompany Revenue showPercentValues1><set labelServicesuidjfkdsjafklsjdfkldgdhjkdfhsgjdkhfsjkhgkjhfdkjhsdkjghdk…

idea的总部_设计IDEA——加拿大鹅上海办公总部

项目概述 | ABOUT项目位于上海延安中路老上海杂技团的旧址&#xff0c;园区初建于20世纪20-30年代&#xff0c;50年代此处成立了上海人民杂技团(上海杂技团的前身)。此后经过整体改造&#xff0c;园区保留了所有历史性建筑&#xff0c;现在此区域目前已经成为影视戏剧等创造性工…

超人名片_老超人

超人名片Prior to php 4.1. there were no $_POST, $_GET, etc. superglobal arrays, but there were a bunch of other superglobals, like $HTTP_POST_VARS, $HTTP_GET_VARS and so on. The guide mentions this in the forms chapter but there is a typo (repeated several…

ZCE证书

Click for a larger view of the print certificateThats the ZCE logo / sticker 点击查看大图印刷证明书那是ZCE徽标/贴纸 Wo-hoo! The printed certicate found its way to my wall &#x1f642; Technically I received it on Tuesday (May 17th), which is about 6 wee…