Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 通过在原始列表中移动,将唯一列表重新排序到另一个列表_List_Algorithm_Sorting_Language Agnostic_Unique - Fatal编程技术网

List 通过在原始列表中移动,将唯一列表重新排序到另一个列表

List 通过在原始列表中移动,将唯一列表重新排序到另一个列表,list,algorithm,sorting,language-agnostic,unique,List,Algorithm,Sorting,Language Agnostic,Unique,我正在寻找一种在任何命令式编程语言中通过移动原始列表来将唯一列表重新排序到另一个列表的算法 输入: items = [a, b, c, d, e] sampleItems = [b, c, e, d, a] items = [b, c, e, d, a] 输出: items = [a, b, c, d, e] sampleItems = [b, c, e, d, a] items = [b, c, e, d, a] items和sample

我正在寻找一种在任何命令式编程语言中通过移动原始列表来将唯一列表重新排序到另一个列表的算法

输入:

items       = [a, b, c, d, e]
sampleItems = [b, c, e, d, a]
items   =     [b, c, e, d, a]
输出:

items       = [a, b, c, d, e]
sampleItems = [b, c, e, d, a]
items   =     [b, c, e, d, a]
items和sampleItems中的项目集相等

重新排序应通过移动原始列表(项目)来执行

void移动(int-oldIndex,int-newIndex)
{
项目=项目[旧索引];
项目移除(旧索引);
项目。插入(项目,新索引);

}
下面是一个没有字典的实现:

使用系统;
使用System.Collections.ObjectModel;
使用系统诊断;
使用System.Linq;
名称空间控制台App14
{
班级计划
{
静态void Main(字符串[]参数)
{
ObservableCollection items=新的ObservableCollection();
整数计数=10001;
for(int i=0;irandom.Next());
秒表秒表=Stopwatch.StartNew();
int-oldIndex=0;
项目样本项目;
Item nextSampleItem=null;
for(int i=0;i}
下面是一个没有字典的实现:

使用系统;
使用System.Collections.ObjectModel;
使用系统诊断;
使用System.Linq;
名称空间控制台App14
{
班级计划
{
静态void Main(字符串[]参数)
{
ObservableCollection items=新的ObservableCollection();
整数计数=10001;
for(int i=0;irandom.Next());
秒表秒表=Stopwatch.StartNew();
int-oldIndex=0;
项目样本项目;
Item nextSampleItem=null;
for(int i=0;i